Skip to content

Instantly share code, notes, and snippets.

@sankarcheppali
sankarcheppali / arduino_nodemcu_mqtt_serial_bridge.ino
Last active January 28, 2018 16:38
arduino code for nodemcu/esp8266 for connecting to mqtt broker. It can receive and send messages to MQTT broker
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.
const char* ssid = "SSID";
const char* password = "passowrd";
const char* mqtt_server = "iot.eclipse.org";
#define mqtt_port 1883
#define MQTT_USER "username"
@sankarcheppali
sankarcheppali / nodemcu_serial_mqtt_publish.ino
Created April 13, 2018 16:12
read UART data and send messages to MQTT broker
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.
const char* ssid = "SSID";
const char* password = "password";
const char* mqtt_server = "iot.eclipse.org";
#define mqtt_port 1883
#define MQTT_USER "mqtt username"
@sankarcheppali
sankarcheppali / mongo-db-cursor-example.js
Created September 27, 2019 02:05
generate report on a mongodb collection using nodejs
const mongoose = require('mongoose')
const util = require('util')
const stream = require('stream')
const pipeline = util.promisify(stream.pipeline)
const stringify = require('csv-stringify')
const fs = require('fs')
const fsp = require('fs').promises
let schema = mongoose.Schema({
@sankarcheppali
sankarcheppali / Pair.java
Created December 28, 2019 06:41
Generic pair class
public class Pair<T,R> {
private T key;
private R value;
public Pair(T key, R value) {
this.key = key;
this.value = value;
}
public T getKey() {
@sankarcheppali
sankarcheppali / flutter-image-upload.dart
Created January 25, 2020 10:58
flutter image upload
import 'package:flutter/material.dart';
import 'package:path/path.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io';
import 'dart:async';
import 'package:dio/dio.dart';
/**
* accepts three parameters, the endpoint, formdata (except fiels),files (key,File)
* returns Response from server
@sankarcheppali
sankarcheppali / dart-file-upload.dart
Created January 25, 2020 11:03
dart file upload
import 'package:path/path.dart';
import 'dart:io';
import 'dart:async';
import 'package:dio/dio.dart';
/**
* accepts three parameters, the endpoint, formdata (except fiels),files (key,File)
* returns Response from server
*/
Future<Response> sendForm(
import 'package:path/path.dart';
import 'dart:io';
import 'dart:async';
import 'package:dio/dio.dart';
/**
* accepts two parameters,the endpoint and the file
* returns Response from server
*/
Future<Response> sendFile(String url, File file) async {
import 'package:flutter/material.dart';
import 'package:path/path.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io';
import 'dart:async';
import 'package:dio/dio.dart';
/**
* accepts two parameters,the endpoint and the file
@sankarcheppali
sankarcheppali / blue_pill_dino_player.ino
Created June 14, 2020 12:35
blue pill based dino player
#define KEYBOARD_ENABLE_CONTROL PB2
#define LDR_PIN PA4
#define LDR_OBSTACLE_THRESHOLD 980
#include "Keyboard.h"
void setup() {
Serial.begin(115200);
pinMode(LDR_PIN,INPUT);
pinMode(KEYBOARD_ENABLE_CONTROL,INPUT);
@sankarcheppali
sankarcheppali / serial-api-blink.ino
Last active August 23, 2020 11:45
control arduino on board led using serial api