Skip to content

Instantly share code, notes, and snippets.

View wduraes's full-sized avatar

Wellington Duraes wduraes

View GitHub Profile
Pre-requirement: before changing the ESP32 sample to use NVS, please follow the sample in the official repo to ensure the basic environment, toolchain and your code are all correct.
This file shows the changes needed to separate the device credentials from the sample binaries in 2 steps:
1. Add the Azure credentials to the device's NVS (non-volatile storage)
2. Change the sample so it can read NVS data
STEP 1
//this sample code reuses nvs_value_sample from Espressif
//the original can be found under ESP-IDF/examples/storage/nvs_rw_value
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "nvs_flash.h"
#include "nvs.h"
@wduraes
wduraes / LCD-clock.ino
Last active February 17, 2021 01:00
Source code for the bare metal clock with RTC
//Bare metal LCD sample
//This sketch will show the light reading in the display
#include <LiquidCrystal.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include "SPI.h"
//#include "sensorData.h"
#include "RTClib.h"
@wduraes
wduraes / grain-silo.ino
Last active March 11, 2022 05:49
Telemetry and Command sample for a grain silo with the ESP8266
/*
*
* Deprecation note: this Gist is here only for historic purposes.
* It was created before the release of the Arduino Library
* which is now the preferred way to get Arduino-based devices to get connected to Azure
* Please refer to https://aka.ms/arduino for additional guidance
*
*/
#include <string.h>
@wduraes
wduraes / arduino.json
Created June 3, 2020 01:19
Arduino setup
{
"configurations": [
{
"name": "Win32",
"defines": [
"ARDUINO=10800",
"USBCON"
],
"includePath": [
"C:\\Program Files (x86)\\Arduino\\tools\\**",
@wduraes
wduraes / ESP8266-Sensors.ino
Last active August 7, 2021 15:22
Sample telemetry code
/*
How to get this sample to run:
https://github.com/ewertons/azure-sdk-for-c/wiki/How-to-setup-and-run-Azure-SDK-for-Embedded-C-IoT-Hub-client-on-Esp8266-NodeMCU
*/
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <time.h>
#include <PubSubClient.h>