Arduino Sensors – Sender

Arduino Sensors – Test Sender


IMG 3224

This is the code for the test devices based on Arduino UNO.

The Duemilanove has hard coded values while the UNO a sensor.

This is the code for 1 (Duemilanove with no sensors).  As the sensors come in will be adding to the sketch and simply un commenting the required calls for the target device.

The posted data log like this,


Again, I want the same code for the Arduino and the ESP based boards.  


#include "DHT.h"
#include <SPI.h>
#include <LoRa.h> 
#include <ArduinoJson.h>
#define DHTTYPE DHT11
const int DHTPin = 8;
int counter = 0;
void setup() {
  Serial.println("LoRa JSON Sender");
  // DT11 Sensor
  pinMode(DHTPin, INPUT);
  //RA02 Module
  if (!LoRa.begin(433E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
    Serial.println("Starting LoRa Success!");
void loop() {
  // Setup 
  StaticJsonDocument<128> doc;  
//  float h = dht.readHumidity();
//  float t = dht.readTemperature();
  float t = 21.5;
  float h = 75;
  float b = 1000;
  // ID. Match to DeviceInfo table
  // 1 = Duemilanove no sensors
  // 2 = UNO with DF11
  doc["id"] = 1;
  // Sensors or preset 
  doc["t"] = t;
  doc["h"] = h;
  doc["b"] = b;
  doc["d"] = -1; 
  JsonArray data = doc.createNestedArray("gps");
  data.add( -37.691);
  String output;
  serializeJson(doc, output);
  if (1){  // Check what was sent
    // Decode JSON and print serial 
    serializeJsonPretty(doc, Serial);

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: