Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / esp32_serial_mqtt_publish.ino
Last active January 20, 2021 05:29
Interfacing arduino uno with ESP32
#include <WiFi.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.
const char* ssid = "SSID";
const char* password = "password";
const char* mqtt_server = "broker.mqtt-dashboard.com";
#define mqtt_port 1883
#define MQTT_USER "mqtt username"
@sankarcheppali
sankarcheppali / esp32_mqtt_led_on_off.ino
Last active March 1, 2018 09:44
control leds using ESP32 and MQTT
#include <WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.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 "username"
@sankarcheppali
sankarcheppali / esp32_serial_mqtt_pub_sub.ino
Last active September 22, 2018 14:15
esp32 will publish message received from serial line to mqtt broker, writes messages received from mqtt broker to serial line
#include <WiFi.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.
const char* ssid = "SSID";
const char* password = "pwd";
const char* mqtt_server = "iot.eclipse.org";
#define mqtt_port 1883
#define MQTT_USER "username"
@sankarcheppali
sankarcheppali / uno_send_a0_on_serial.ino
Created December 7, 2017 16:51
reads A0 pin data ,prepares a JSON and sends on serial line every 5 seconds
int id=99;
#include <SoftwareSerial.h>
SoftwareSerial sw(2, 3); // RX, TX
void setup() {
Serial.begin(115200);
Serial.println("Interfacfing arduino with nodemcu");
sw.begin(115200);
}
@sankarcheppali
sankarcheppali / CustomAdapter.java
Created November 14, 2017 17:59
Text view On click : Show list view : On click item : show selected item in TextView
package com.anhure.test3.test3android;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
@sankarcheppali
sankarcheppali / itc_queues.c
Created August 25, 2017 19:20
inter task communication using queues
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
QueueHandle_t q=NULL;
void consumer_task(void *pvParameter)
{
unsigned long counter;