← Zurück zur Übersicht

IOT17 IOT App with LORAWAN,MQTT and ISOagriNET

Veröffentlicht am 2020-11-15 00:00:00.0


IOT17 IOT App with LORAWAN,MQTT and ISOagriNET

NETWORKING WITH IOT

MQTT with GROOVY

public void doDemo() {
try {
        client = new MqttClient("tcp://localhost:1883", "Sending");
        client.connect();
        client.setCallback(this); 
        client.subscribe("channel/908020/temp");
       def dmap = [:]
       dmap << ["device_id":1234567];
       dmap << ["device_type":"Arduino Uno"]
       dmap << ["time":"2019-11-14 11:10:00.222"];
       dmap << ["entity":"soilmessurements"]
       dmap << ["soiltemp":"25.0"];
       dmap << ["soilhumidity":"5.0"]
       def json = JsonOutput.toJson(dmap);
       MqttMessage message = new MqttMessage();
       message.setPayload(json.getBytes());
       client.publish("channel/908020/temp", message);
   } catch (MqttException e) ...
}

public void messageArrived(String topic, MqttMessage message) throws Exception { System.out.println("This message arrived:"+message); }

Mosquitto configurations

You can configure:

  1. Default listeners
  2. Extra listeners
  3. Persistence
  4. Bridges

Mosquitto and CA-Files

1.cafile Path to a cafile 1.capath Path to a directory with CA-Files 1.certfile Path to the PEM encoded server certificate 1.keyfile Path to the PEM encoded keyfile. 1. psk_hint option enables pre-shared-key support for this listener and also acts as an identifier for this listener

Note that the recommended port for MQTT over TLS is 8883, but this must be set manually.

ARDUINO C++

The Ardunio IDE supports C++, so the best thing is to learn C++. There are other alternatives like python and lua, but I 'm sure, if and how they support all the libraries.

dtostrf() convert from "Float" to char array

params

  1. the float value
  2. length of the whole string
  3. digits after the dot
  4. name of the result char array

Example:

char PufferChar1[20]; dtostrf(123.456789, 1, 5,PufferChar1); Serial.println(PufferChar1);

ARDUINO C++ Numeric Functions

int a = 1234; String myStr; myStr = String(a); //Converts integer to string

String val = “1234”; int result = val.toInt(); //Converts string to integer int to string conversion

2 PILOT-Projects - Your Experience

My Projects LoRaWan

  1. LoRaWan with the Dragino-Gateway
    1. At home I use the TTN-Forwarder, it works OK
    2. MQTT works good for uploading data from the Node
    3. there are not even examples how to download data (subscribe) from MQTT (with TTN it works)
    4. in a next step I could prepare that

My Projects MQTT

  1. Develop the Software for MQTT - communication with Mosquitto, ESP32, flutter,red-node and IOT-MQTT-Panel
  2. I spend much time to work with the MQTT-Lib for ESP32 pubsubclient, which seems to be the mainly used Lib for MQTT
    1. publish data from a BME280 (SPI/I2C) is never a problem
    2. subscribe only works for a small time
    3. perhaps it is question of timing-problems, some weaknesses in the WIFI-Lib on ESP32
    4. perhaps its also question, how much traffic is on the local network

My Projects MQTT

  1. Now I just try two other libraries
    1. AsyncTCP
    2. AsyncMQTT s. AsyncMQTTTestAdopted4BME280
    3. These fit my requirements. Just try to reconnect, if the payload-id coming back from the broker is Zero. ```

      include

uint16t packetIdPub2 = mqttClient.publish("esp32/temperature", 2, true, temperatureString.cstr()); Serial.println(packetIdPub2); if (packetIdPub2 == 0){ connectToWifi(); }

My Projects MQTT

  1. Flutter is a development tool for IOS and Android written with dart
  2. using RED NODE for prototyping. It is a very good way to make prototyping for IOT with LORAWAN and MQTT
  3. using IOT-MQTT-Panel, an MQTT App for Android
  4. using a Paho-Java-Api to write a small groovy client, which works even well

My Projects UDP/TCP

1 UDP and Multicast with GROOVY on the PC and with C++ on the ESP32 (Multicast has a Problem on ESP32) 1.TCP-Example

What is the target of your IOT-training of teachers

What we learned from your projects

1.Not every sensor worked as expected 1. Both projects fit the needs for training teachers, if the maaterial is so improved that they will finish in less one week 1. If the material improves, it will work better 1. The teams themselv have learned much in the projects. The teachers even will.

What could improve the projects

  1. pluggable, ready to use modules
  2. learning C++ in the beginning, if this is used, on Raspberry Pi Python could be an alternative
  3. taking more poweful embedded devices for some work
  4. learn basic electronics before procjects start
  5. learn network protocols
  6. learn some IOT-frameworks

MQTT

TODO

  1. I will install gitea on my server leever-miteenanner But you have to wait for that. There I will publish all projects connected to TPTC
Info

Diese Seite wurde dynamisch aus Groovy-DSLs generiert.


User: