This is a java based code generated that can be used to generate code for flashing into the ESP8266 on a mass scale or for a single device. This code generation is only for the MQTT based data collection from the edge device.
The code by default send data as JSON from the edge device to the Server. The example format will be
{ “Temperature” : “22” “Humidity” : “47” “Time” : “1519286030” “Client_id”:”humidity-sensor-production-floor” }
The number of fields and the value type can be specified by the developer during the generation of the code. The time and the client field can be automatically added baed on the option yes or no.
You will be able to specify the following details as inputs for the code generation.
- Parameters to be send on the message and the data type
- Topic to which the message to be published
- Time interval between each publish
- MQTT Server Name and Remote Port
- Wireless Access point details if behind the firewall.
The code generation follows two modes
- Command line
- Automated Generation
This option can be mostly used for a single device code generation
This option can be used when you are doing mass production of sensors and you can integrated the code generation into your system for the code generation by varying the client id, authentication, wifi parameters and the topic name as needed.
The java API document will provide the necessary API for the auto generation available under the JavaDoc folder or available online at Bevywise Code Generation API .
The below packages should be added to the Arduino->Libraries/ Folder.
1.pubsubclient Library 2.ArduinoJson Library 3.WiFiManager Library 4.NPClient Library
- Set up your Arduino IDE and the required tools for the ESP8266
- Download the dependencies and paste it in Arduino->Libraries Folder
- Clone the repo - Go to Source/ folder
- Compile the Java Code - javac - d . com/bevywise/iot/client/CodeGenForESP8266.java
- Run the code - java com.bevywise.iot.client.CodeGenForESP8266
- Provide the details needed and get the code generator.
- Copy paste the Instrumentation library in the Arduino / Libraries folder of Arduino.
- Once the code is generated, Create a new file in Arduino and copy paste the content of ESPMain.cpp
- If you are going to send the time data from the agent, copy paste the time
- You may need to customise the code to read the data from the GPIO and use the necessary logic to convert the data. You can also add your own code for the algorithm in the CodeGenForESP8266.java and automate it completely.
If you have any questions you can connect with us via support