WiFi connectivity module for SAM Element.

N|Solid

ACS-M1128 SAM Element IoT WiFi Connectivity

SAM Element is an IoT platform. Visit our website to get to know more.

Quick Links & Requirements

TESTED (Latest Version):

  • Tested with ESP8266 Board library v2.5.2
  • Tested with ESP32 Board library v1.0.4
  • It has come to our attention that some may experience sketch data upload problem when using ESP8266 board library v2.6.1 with ESP8266FS uploader plugin v0.4.0. Please follow this issue to get solution.

Caution:

  • You must maintain publish rate at minimum 10s.
  • SAM Element may suspend an account when an abusive behaviour detected.

WiFi Connectivity

  • Supported board: ESP32, ESP8266.
  • Easy connect to SAM Element IoT platform.
  • Ready to use some working examples for real application.
  • WiFi configuration page ready.
  • Auto Access Point.
  • Embedded factory reset.
  • Custom serial number.
  • Secure connection.
  • You just need to focus on sensors/actuators, we handle the rest.

How to Use

Example connection below (and examples folder) is done for ESP8266-01. You may need to made some adjustment for different board.

Define default values

// get your account details in your dashboard
// DO NOT use existing developer user & pass in example as we do not guarantee it will work and for how long.
#define DEVELOPER_ROOT "<insert your developer root>" 
#define DEVELOPER_USER "<insert your API Device username>"
#define DEVELOPER_PASS "<insert your API Device password>"

#define WIFI_DEFAULT_SSID "MySmartDevice" // create your own custom SSID
#define WIFI_DEFAULT_PASS "abcd1234" // put a password 8-63 chars.

Define IoT object & other necessary objects

HardwareSerial *SerialDEBUG = &Serial; // optional if you wish to debug
M1128 iot;

Basic Initialization

void setup() {  
  // pass your developer details
  iot.devConfig(DEVELOPER_ID,DEVELOPER_USER,DEVELOPER_PASS);
  // pass your default SSID config. Optional params are: IPAddress localip, IPAddress gateway, IPAddress subnet
  iot.wifiConfig(WIFI_DEFAULT_SSID,WIFI_DEFAULT_PASS); 
  iot.init(); // pass client
}

Advanced Initialization

  // If you want to debug, initialize your SerialDEBUG
  SerialDEBUG->begin(DEBUG_BAUD, SERIAL_8N1, SERIAL_TX_ONLY);
  while (!SerialDEBUG);
  SerialDEBUG->println("Initializing..");
  
  pinMode(3, FUNCTION_3); // this will set GPIO3 (RX) to be used as input
  iot.setId("ABCDEXFGH"); // set device serial number, default is retrieved from ESP.getChipId()

  // When ESP is sleeping, pin reset will only works when device is waking up.
  // When ESP is sleeping forever, the only way to make the pin factory reset to work is by trigger it while you turn it on. 
  iot.pinReset = 3; // optional to set the factory reset pin to GPIO3, default is GPIO3
  
  // autoAP is an option to allow ESP automatically set up as AP. Default value is false
  // If set to true, when first turn on, it will go to AP if wifi connect failed.
  // Other way to go to AP is by trigger pin reset.
  iot.autoAP = false;
  
  //set whether you want to use sandbox or production server. default is sandbox (prod=false).
  iot.prod = true;
  
  //set the expire of access token in seconds. default is 43200 = 12 hours. max is 49 days.
  iot.accessTokenExp = 43200; // 12 hours
  
  //set whether mqtt will init in clean session. default  is false.
  iot.cleanSession = true;
  
  //set whether you like to use LWT message. default is true.
  iot.setWill = true;
  
  // optional set wifi connect trial before going to AP mode, default is 1  
  iot.wifiConnectRetry = 2; 
  
  // apConfigTimeout is a timeout for ESP when it works as soft AP.
  // use apConfigTimeout for low battery powered device to make sure ESP not work as AP too long. 
  // apConfigTimeout is in ms. Default is 0, which means no timeout.
  // When apConfigTimeout has passed, it will trigger onAPConfigTimeout.
  iot.apConfigTimeout = 300000;

  // if apConfigTimeout > 0 and and apConfigTimeout has passed, it will trigger a callback you can define here.
  // if this callback is not defined then after timeout it will goes to deep sleep.
  iot.onAPConfigTimeout = callbackOnAPConfigTimeout; 
  
  // wifiConnectTimeout is a timeout for ESP to keep try to connect to a WiFi AP.
  // wifiConnectTimeout is in ms. Default is 0, which means no timeout.
  // When wifiConnectTimeout has passed, it will trigger onWiFiConnectTimeout.
  iot.wifiConnectTimeout = 120000;

  // if wifiConnectTimeout > 0 and and wifiTimeout has passed, it will trigger a callback you can define here.
  // if this callback is not defined then after timeout it will goes to deep sleep.
  iot.onWiFiConnectTimeout = callbackOnWiFiConnectTimeout; 
  
  iot.onReceive = callbackOnReceive; // optional callback when message received
  iot.onReset =  callbackOnReset; // optional callback when device factory reset pressed
  iot.onConnect = callbackOnConnect; // optional callback when connected to server
  iot.onReconnect = callbackOnReconnect; // optional callback when reconnected to server
  iot.onWiFiConfigChanged = callbackOnWiFiConfigChanged; // optional callback when wifi config changed

  ESP.wdtEnable(8000); // if you wish to enable watchdog
  iot.init(SerialDEBUG); //use debug (optional).

Define necessary callbacks you wish to use

void callbackOnReceive(char* topic, byte* payload, unsigned int length) {
    // your codes
}
void callbackOnReset() {
    // your codes
}
void callbackOnConnect() {
    // your codes
    // start publish your MQTT message and
    // start subscribe to MQTT topics you wanna to listen
}
void callbackOnReconnect() {
    // your codes
    // if you use set clean_session=true, then you need to re-subscribe here
}
void callbackOnWiFiConfigChanged() {
    // your codes
}
void callbackOnAPConfigTimeout() {
    // ESP.deepSleep(0);
    // iot.restart(); // call to restart via software
    // iot.reset(); // call to reset the wifi configuration saved in ESP, this will trigger onReset()
    // your codes
}
void callbackOnWiFiConnectTimeout() {
    // ESP.deepSleep(0);
    // iot.restart(); // call to restart via software
    // iot.reset(); // call to reset the wifi configuration saved in ESP, this will trigger onReset()
    // your codes
}

Codes in Loop

void loop() {
  ESP.wdtFeed(); // if you enable watchdog, you have to feed it
  iot.loop();
  // your other codes
}

How to Flash

In every newly created project, there are 2 steps to upload your project:

  • Upload WiFi Configuration Interface files with SPIFFS Data Uploader, via menu Tools -> ESP8266 Sketch Data Upload.
  • Upload your sketch as usual through Sketch -> Upload (or via Upload button)
Similar Resources

Arduino library for making an IHC in or output module using an Arduino

Introduction This is an Arduino library for making an IHC in or output module using an Arduino. (IHC controller is a home automation controller made b

Mar 26, 2020

IA-LIO-SAM is enhanced LIO-SAM using Intensity and Ambient channel from OUSTER LiDAR.

IA-LIO-SAM is enhanced LIO-SAM using Intensity and Ambient channel from OUSTER LiDAR.

IA-LIO-SAM Construction monitoring is one of the key modules in smart construction. Unlike structured urban environment, construction site mapping is

Dec 13, 2022

Given two arrays X and Y of positive integers, find the number of pairs such that x^y y^x (raised to power of) where x is an element from X and y is an element from Y.

Number-of-pairs Given two arrays X and Y of positive integers, find the number of pairs such that x^y y^x (raised to power of) where x is an element

Nov 20, 2021

Updated Vindriktning with Wifi Connectivity, Motion sensor, Temperature and Humidity

Updated Vindriktning with Wifi Connectivity, Motion sensor, Temperature and Humidity

Vindriktning-plus Updated Vindriktning with Wifi Connectivity, Motion sensor, Temperature and Humidity Inspired & parts of the code are used from: htt

Sep 20, 2022

Bluetooth Joystick : A wireless joystick with ESP-32 microcontroller and Dual Axis Joystick Module using the Bluetooth connectivity.

Bluetooth Joystick : A wireless joystick with ESP-32 microcontroller and Dual Axis Joystick Module using the Bluetooth connectivity.

BluetoothJoystick Bluetooth Joystick : A wireless joystick with ESP-32 microcontroller and Dual Axis Joystick Module using the Bluetooth connectivity.

Feb 24, 2022

WiFi Attack + Recon Suite for the ESP8266 WiFi Nugget

Nugget-Invader Welcome to the Nugget Invader repository! The Invader is a WiFi attack suite developed for the WiFi Nugget, an ESP8266 based platform d

Nov 28, 2022

GStreamer source element for AirPlay video streams

GStreamer source element for AirPlay video streams

A GStreamer plugin that provides an airplaysrc element for receiving video streamed from Apple devices using the AirPlay protocol.

Dec 22, 2022

LIO-SAM: Tightly-coupled Lidar Inertial Odometry via Smoothing and Mapping

LIO-SAM: Tightly-coupled Lidar Inertial Odometry via Smoothing and Mapping

A real-time lidar-inertial odometry package. We strongly recommend the users read this document thoroughly and test the package with the provided dataset first.

Jan 4, 2023

LVI-SAM: Tightly-coupled Lidar-Visual-Inertial Odometry via Smoothing and Mapping

LVI-SAM: Tightly-coupled Lidar-Visual-Inertial Odometry via Smoothing and Mapping

LVI-SAM This repository contains code for a lidar-visual-inertial odometry and mapping system, which combines the advantages of LIO-SAM and Vins-Mono

Jan 8, 2023

Defender(1981) by Eugene Jarvis and Sam Dicker

Defender(1981) by Eugene Jarvis and Sam Dicker

Defender (1981) by Eugene Jarvis and Sam Dicker This is the source code for the Williams arcade game Defender. The source code can be assembled into a

Nov 27, 2022

This speech synthesizer is actually the SAM speech synthesizer in an ESP8266

SSSSAM Serial Speech Synthesizer SAM This speech synthesizer is actually the SAM speech synthesizer in an ESP8266. Where SAM was a software applicatio

Oct 4, 2022

Chromium fork for linux named after radioactive element No. 90

Thorium Chromium fork for linux named after radioactive element No. 90 Always built with latest x64 tip-o-tree "Trunk" build of chromium \ Intended to

Jan 1, 2023

Chromium fork for windows named after radioactive element No. 90

Chromium fork for windows named after radioactive element No. 90

Chromium fork for windows named after radioactive element No. 90

Jan 7, 2023

SAM (Software Automatic Mouth) for Godot

gdsam SAM (Software Automatic Mouth) for Godot 3.4+ A GDNative library wrapper around the C port of SAM by Sebastian Macke over at https://github.com/

Dec 28, 2021

SuanPan - 🧮 An Open Source, Parallel and Heterogeneous Finite Element Analysis Framework

SuanPan - 🧮 An Open Source, Parallel and Heterogeneous Finite Element Analysis Framework

suanPan Introduction 🧮 suanPan is a finite element method (FEM) simulation platform for applications in fields such as solid mechanics and civil/stru

Dec 27, 2022

ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT Cloud

ArduinoIoTCloud What? The ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT

Dec 16, 2022

This project was made with a NodeMCU ESP8266 WiFi module, Raspberry Pi4, humidity sensor, flame sensor, luminosity sensor, RGB LED, active buzzer.

This project was made with a NodeMCU ESP8266 WiFi module, Raspberry Pi4, humidity sensor, flame sensor, luminosity sensor, RGB LED, active buzzer.

Smart.House.IoT.Project This project was made with a NodeMCU ESP8266 WiFi module, Raspberry Pi4, Temp and Humidity sensor, Flame sensor, Photoresistor

Jun 22, 2022

A WiFi mapping companion app for Valetudo

A WiFi mapping companion app for Valetudo

Valeronoi (Valetudo + Voronoi) is a companion for Valetudo for generating WiFi signal strength maps. It visualizes them using a Voronoi diag

Jan 8, 2023

Tuya IoTOS Embeded SDK WiFi & BLE for BK7231T

Tuya IoTOS Embedded Wi-Fi and BLE SDK for BK7231T 中文版 | English Overview Developed independently by Tuya Smart, Tuya IoTOS is the world's only IoT ope

Dec 5, 2022
Comments
  • Revert library name change

    Revert library name change

    Libraries are locked to the name value specified by the library.properties metadata file in the release at the time of the Library Manager submission.

    Any release with a different name is rejected by the Arduino Library Manager indexer.

    References:

    • https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ#why-arent-releases-of-my-library-being-picked-up-by-library-manager
    • https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ#how-can-i-change-my-librarys-name
  • Failed to upload Sketch Data Upload

    Failed to upload Sketch Data Upload

    Describe the bug Waktu sketch data upload, hasilnya failed.

    To Reproduce Steps to reproduce the behavior:

    1. Open sketch example, apapun.
    2. Pasang board esp8266-01 ke programmer dlm mode programming
    3. Klik Tools->ESP8266 Sketch Data Upload
    4. Upload failed.

    Expected behavior Mestinya berhasil bukankah begitu?

    Screenshots

    Board & Model/Version:

    • ESP8266-01
Library code for Adafruit's CC3000 WiFi breakouts &c

Adafruit CC3000 Library This is a library for the Adafruit CC3000 WiFi Breakouts etc Designed specifically to work with the Adafruit CC3000 Breakout -

Sep 9, 2022
Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.
Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.

Adafruit IO Arduino Library This library provides a simple device independent interface for interacting with Adafruit IO using Arduino. It allows you

Dec 23, 2022
♾ The All-New AllThingsTalk Arduino SDK for WiFi Devices
♾ The All-New AllThingsTalk Arduino SDK for WiFi Devices

AllThingsTalk Arduino WiFi SDK AllThingsTalk Arduino Library for WiFi Devices - makes connecting your devices with your AllThingsTalk Maker a breeze.

Jul 21, 2022
The Approximate Library is a WiFi Arduino library for building proximate interactions between your Internet of Things and the ESP8266 or ESP32
The Approximate Library is a WiFi Arduino library for building proximate interactions between your Internet of Things and the ESP8266 or ESP32

The Approximate Library The Approximate library is a WiFi Arduino Library for building proximate interactions between your Internet of Things and the

Dec 7, 2022
ESP32 Temp Alarm using DS18B20, wifi manager, Email alert Threshold
ESP32 Temp Alarm using DS18B20, wifi manager, Email alert Threshold

ESP32-Freezer-Alarm ESP32 Temp Alarm using DS18B20, wifi manager, Email alert Threshold. I made this alarm using several tutorials from https://random

Oct 7, 2022
Library for Arduino UNO WiFi Developer Edition

Note: This library will no longer be maintained by Arduino. Uno WiFi Developer Edition Library Library for Arduino Uno WiFi Developer Edition For more

Feb 7, 2022
ESPHome custom component for Linptech G6L-WIFI

ESPHome custom component for Linptech G6L-WIFI (linp-doorbell-g04) Background The Linptech G6L-WIFI is a wifi doorbell with a self-powered button. It'

Dec 16, 2022
Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.
Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.

107-Arduino-NMEA-Parser Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages. This library

Jan 1, 2023
Framework for create a AIO module on NODEMCU using Arduino IDE

AIO MODULE Install Add library Best thing is to use the Arduino Library Manager. Go to Sketch > Include Library > Manage Libraries. Install WebSockets

Mar 29, 2022
Library to add a TapNLink module in a few minutes

Arduino-Tap The tap library allows an Arduino board to be connected to a TapNLink using S3P protocol. The main characteristics of the TapNLink solutio

Dec 1, 2022