Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
| ||||||
| ||||||
| ||||||
|
The waste from our houses and from various factories are dumped in the form of those massive landfills. Most of that waste is not recycled and much may be organic. This organic compounds on decomposing and then combining with inorganic waste from factories make harmful gases like all the volatile organic compounds (VOC), along with Methane, CO2, Ammonia, Sulfides, disulfides, mercaptans etc. Plastics also burn to release Benzene and toluene which are VOCs. All of this gases are harmful to nature and humans. Most of this gases have the concentration increased very rapidly and are harmful to the people. These gases (like CH4) catch on fire causing more pollution. According to a report by sciencedaily.com, the H2S Gas from landfills causes lung cancer and other gases cause other diseases like Bronchitis also. This makes it unhealthy to live near landfills with a layer of polluted air over the vast area. And moreover, it is very difficult to monitor the vast areas. The current sensors are very bulky and need to be replaced with small and independent interconnected devices.
Concept/Solution/Goal
The simple solution is to monitor this vast landfills and then report the data to authorities. Based on various concentration levels that particular area can be cleaned. Also, if the levels are too high then the citizens can be warned. To monitor this vast areas the solution is to create many interconnected nodes that communicate to a central server where all the data is saved and managed. Also if there is fire, the temperature and CO2 contents rise rapidly so we can have a fire fighting team to extinguish it and not let more of waste to burn and cause pollution.
So, We have Rapid IOT Prototyping Kit that has many sensors and a Raspberry Pi that can communicate with Rapid IOT via BLE and get the data. This data can be stored and help the authorities to see the periodic changes and also warn the people. But, it is must to keep the gateways secured as if the data is changed then it can be a big problem.
Materials & Software Required
- NXP Rapid IOT prototyping Kit
- RPi 3B/3B+/3A+ >> as they have BLE in them
- Python > best language
- Rapid IOT studio >for coding Rapid IOT
- InfluxDB >Database
- Mosquitto >Handle MQTT requests
- Node-Red >Manage flow of data
- Grafa >Display all the data
More information on top
NXP's Rapid IOT Kit is a All-In-One which can help makers to easily and quickly make their project and have a ready prototype. Also with the use of its industry grade sensors, it is also very easy to convert it into ready - perfect product.
Features
- Kinetis® K64 MCU based on Arm® Cortex®-M4 Core
- KW41Z Wireless MCU (BLE, Thread, Zigbee)
- NT3H2211 NFC Forum Type 2 Tag
- A1006 Secure Authentication & anti-counterfeit IC
- Multiple sensors (Gyroscope, Acc/Mag., Barometer/Temp., Air Quality, Ambient light and capacitive touch)
- Rapid IoT Studio IDE
- Automatic source code & project generation for MCUXpresso IDE/SDK
- iOS/Android mobile apps and IoT Cloud connect platforms
- Expandable to most IoT end-node use cases with 400+ Click boards™
- Compatible with NXP IoT Modular Gateway
We will use the following sensors for our project:
- Temperature and Humidity Sensor >for general data and also detection of fires
- Air Pressure Sensor >with help of pressure concentrations at various locations, the direction of fire with the wind can be determined.
- CO2 and VOC sensor >main gases for being notorious and directly proportional to size and pollution in landfill
- Light Sensor >for detecting day and night and light distribution and light intensity as it directly depends on the severity of fire
All the sensors i.e., ENS210;MPL3115;CCS811;TLS2572 are present in the Rapid IOT for their respective functions.
Coding the Rapid IOTTo code the Rapid IOT is extraordinarily simple. It has an online GUI drag and drop IDE with which you can fully create the project and even use it to make your project. It consists of connected nodes like things which have specific meaning and the AtMo language which is the backbone is like Java and has lots of inheritance and calling of methods.
We can easily program it with the studio>
The Atmo code and Source files are attached below.
Though there is a problem in CO2 reading in the GUI based studio, it will not read the CO2 values as there is some problem in backed code. So for that you have to keep it as measurement for VOC then change the code in Atmo language which can be done by option to switch to pure code. While parsing you need to change from
ATMO_Status_t GetAirQualityStr_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
unsigned int temp;
ATMO_GetUnsignedInt(in, &temp);
char str[32];
sprintf(str, "%u ppb", temp);
ATMO_CreateValueString(out, str);
return ATMO_Status_Success;
}
to
ATMO_Status_t GetAirQualityStr_CO2_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
unsigned int temp;
ATMO_GetUnsignedInt(in, &temp);
char str[32];
sprintf(str, "%u ppm", temp);
ATMO_CreateValueString(out, str);
return ATMO_Status_Success;
//return ATMO_Status_Success;
}
And it works!
Then you need to find out the Bluetooth UUIDs of your specific BLE characteristics. UUIDs are Bluetooth identification ID which tell what data is sent with which ID. Like this>
The one in Red is Service UUID which must remain same for all BLE Gatt Characteristics. Make sure of that! And the one in the Black is the UUID for the specific BLE GATT and will be different for all other GATTs.
Just take a note of all that UUIDs as it will be required later.
Also there is option to change the BLE characteristics and use it in in NXP's own app to get the values.
About Raspberry Pi and its UseRaspberry Pi is a very famous single board computer and is also very powerful for its size and price also having a very large community and support.
Here we are using Raspberry Pi to do a lot of stuff as its has a SOC. The RPi handles the BLE connection, Manages data flow, stores the data and also displays it.
Code for RPiFirst you need to find the mac address of your device. For that we can use command line Bluetooth tool.
//execute
bluetoothctl
//this should connect to the Bluetooth modem.
scan on
//with this you will be able to see the list of devices near you
//you can identify your's MAC address by comparing it to one given on back of your device
connect <Mac Adress>
//with this you will connect to the device
pair <Mac Adress>
//with this you will be paired with Rapid IOT and start receiving data with respective UUIDs
//UUIDs are Bluetooth identification ID which tell what data is sent with which ID
The code to get values from BLE connection is very simple. We are using Python script in RPi to connect to device and extract values and then send it via MQTT.
Very simple and commented? Check it below.
You need to replace the UUIDs in the code with the ones you found earlier. Don't forget to replace service UUID!
You can install all the libraries and other dependencies on your fresh Linux distro (recommended : Raspbian) for all the server side things : https://tech.scargill.net/the-script/
You can execute the code by:
python <file name>.py <ble adress of NXP>
// Ex: python MD2.py 00:67:sa:...
Node RedNode red is a nodeJS based GUI controlled programming. Like Rapid IOT studio, you have Nodes (hence : nodered) which are connected with lines and the code flows in the direction of the lines.
Here we are using it to get back the string sent by the python script containing the values and then parsing it to separate all the reading and then storing it in the database. The flow can be found below.
What is InfluxDB?
InfluxDB is a database that is opensource and a easy and quick alternative to SQL or other paid databases.
The main advantages of it over others is:
- Its free to use.
- You need far less coding knowledge and do not need to spend a lot of time in just adding databases, entries and keys and hence you can focus on the result. A big + point against SQL
- The amount of data you can store depends on the available ROM you have but reading although depends upon RAM. But since the NXP's inbuilt data storage has only 100MB this is better.
- You can have some cool features. Like if you are taking readings every 10s which we are here then for a day you can average it to per min, for a month to hour and so on. Hence, we can store more required information in less memory and also amount of resource required to read it is reduced.
- It can be installed locally on any machine rather than rely on third party server. Especially helpful when the data does impact to lot of people and needs to be secured.
- A lot of documentation : https://docs.influxdata.com/influxdb/v1.7/introduction/getting-started/ So that you can easily create and maintain your own database.
What is Grafana?
Grafana is a very useful tool to analyze and show the data over a log period of time. You can easily see the data and see the data of a particular time also very easily. It is also very customizable as it is opensource.
The Grafana dashboard's script can be found below. So that you can import it in your own project and do not need to do all the graph configuration again.
An explanation of project and working demo>>>
Some Debugging and encountered problemsSometimes the python code may not work and give some Bluetooth error. Or while scanning for BLE devices the bluetooth host may not start. So you can check if Bluetooth is on by
rfkill list
//and if it says is software blocked then execute
rfkill unblock bluetooth
//as root
//and it will work.
If you want that the program runs even when you log out of user (via SSH) the you can excecute the code with
nohup python <name of file>.py <ble adress of your Rapid IOT> &
If you want to learn more about InfluxDB and Grafana and if you are facing some installation issues then, this is a good video: https://www.youtube.com/watch?v=JdV4x925au0
ConclusionThis project was a very fun one. And I plan to grow it further. Not necessarily BLE devices, we can use some RF ones also and WiFi is there for our rescue. Also adding a GSM shield to RPi can send the data to cloud in middle of landfill if you are confident about your security.
This project can help the people working in landfills. Also the vast fires that are occurring can be detected by some algorithm and can be extinguished. Which can lead to reduction in pollution. Also the citizens living near the landfills can be warned and the air get cleared by the authorities.
Thanks for Reading :D#include "callbacks.h"
//HEADER START
//HEADER END
void ATMO_Setup() {
}
ATMO_Status_t getHPa_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
unsigned int temp = 0;
ATMO_GetUnsignedInt(in, &temp);
ATMO_CreateValueUnsignedInt(out, temp/100);
return ATMO_Status_Success;
}
ATMO_Status_t FastInterval_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t FastInterval_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_INTERVAL_Handle_t intervalHandle;
ATMO_INTERVAL_AddAbilityInterval(
ATMO_PROPERTY(FastInterval, instance),
ATMO_ABILITY(FastInterval, interval),
ATMO_PROPERTY(FastInterval, time),
&intervalHandle
);
return ATMO_Status_Success;
}
ATMO_Status_t FastInterval_interval(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t TempChar_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t TempChar_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(TempChar, instance),
&ATMO_VARIABLE(TempChar, bleServiceHandle),
ATMO_PROPERTY(TempChar, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(TempChar, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(TempChar, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(TempChar, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(TempChar, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(TempChar, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(TempChar, writeDataType), ATMO_PROPERTY(TempChar, readDataType), ATMO_PROPERTY(TempChar, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(TempChar, instance),
&ATMO_VARIABLE(TempChar, bleCharacteristicHandle),
ATMO_VARIABLE(TempChar, bleServiceHandle),
ATMO_PROPERTY(TempChar, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(TempChar, instance),
ATMO_VARIABLE(TempChar, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(TempChar, written));
return ATMO_Status_Success;
}
ATMO_Status_t TempChar_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(TempChar, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(TempChar, instance),
ATMO_VARIABLE(TempChar, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t TempChar_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(TempChar, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t TempChar_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t TempChar_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t HumidChar_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t HumidChar_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(HumidChar, instance),
&ATMO_VARIABLE(HumidChar, bleServiceHandle),
ATMO_PROPERTY(HumidChar, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(HumidChar, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(HumidChar, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(HumidChar, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(HumidChar, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(HumidChar, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(HumidChar, writeDataType), ATMO_PROPERTY(HumidChar, readDataType), ATMO_PROPERTY(HumidChar, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(HumidChar, instance),
&ATMO_VARIABLE(HumidChar, bleCharacteristicHandle),
ATMO_VARIABLE(HumidChar, bleServiceHandle),
ATMO_PROPERTY(HumidChar, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(HumidChar, instance),
ATMO_VARIABLE(HumidChar, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(HumidChar, written));
return ATMO_Status_Success;
}
ATMO_Status_t HumidChar_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(HumidChar, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(HumidChar, instance),
ATMO_VARIABLE(HumidChar, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t HumidChar_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(HumidChar, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t HumidChar_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t HumidChar_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t LightChar_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t LightChar_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(LightChar, instance),
&ATMO_VARIABLE(LightChar, bleServiceHandle),
ATMO_PROPERTY(LightChar, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(LightChar, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(LightChar, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(LightChar, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(LightChar, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(LightChar, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(LightChar, writeDataType), ATMO_PROPERTY(LightChar, readDataType), ATMO_PROPERTY(LightChar, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(LightChar, instance),
&ATMO_VARIABLE(LightChar, bleCharacteristicHandle),
ATMO_VARIABLE(LightChar, bleServiceHandle),
ATMO_PROPERTY(LightChar, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(LightChar, instance),
ATMO_VARIABLE(LightChar, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(LightChar, written));
return ATMO_Status_Success;
}
ATMO_Status_t LightChar_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(LightChar, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(LightChar, instance),
ATMO_VARIABLE(LightChar, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t LightChar_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(LightChar, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t LightChar_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t LightChar_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t PressureChar_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t PressureChar_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(PressureChar, instance),
&ATMO_VARIABLE(PressureChar, bleServiceHandle),
ATMO_PROPERTY(PressureChar, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(PressureChar, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(PressureChar, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(PressureChar, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(PressureChar, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(PressureChar, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(PressureChar, writeDataType), ATMO_PROPERTY(PressureChar, readDataType), ATMO_PROPERTY(PressureChar, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(PressureChar, instance),
&ATMO_VARIABLE(PressureChar, bleCharacteristicHandle),
ATMO_VARIABLE(PressureChar, bleServiceHandle),
ATMO_PROPERTY(PressureChar, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(PressureChar, instance),
ATMO_VARIABLE(PressureChar, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(PressureChar, written));
return ATMO_Status_Success;
}
ATMO_Status_t PressureChar_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(PressureChar, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(PressureChar, instance),
ATMO_VARIABLE(PressureChar, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t PressureChar_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(PressureChar, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t PressureChar_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t PressureChar_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t VOC_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t VOC_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(VOC, instance),
&ATMO_VARIABLE(VOC, bleServiceHandle),
ATMO_PROPERTY(VOC, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(VOC, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(VOC, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(VOC, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(VOC, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(VOC, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(VOC, writeDataType), ATMO_PROPERTY(VOC, readDataType), ATMO_PROPERTY(VOC, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(VOC, instance),
&ATMO_VARIABLE(VOC, bleCharacteristicHandle),
ATMO_VARIABLE(VOC, bleServiceHandle),
ATMO_PROPERTY(VOC, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(VOC, instance),
ATMO_VARIABLE(VOC, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(VOC, written));
return ATMO_Status_Success;
}
ATMO_Status_t VOC_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(VOC, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(VOC, instance),
ATMO_VARIABLE(VOC, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t VOC_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(VOC, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t VOC_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t VOC_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t MPL3115Pressure_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t MPL3115Pressure_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_MPL3115_Config_t config;
config.address = ATMO_PROPERTY(MPL3115Pressure, i2cAddress);
config.i2cDriverInstance = ATMO_PROPERTY(MPL3115Pressure, i2cInstance);
config.MPLsettings.mode = MPL_MODE_PRESSURE;
config.MPLsettings.oversample = MPL_OS_0; // oversampling = 1
config.MPLsettings.autoAcquisitionTime = MPL_ST_0; // Auto acquisition time = 1s
config.MPLsettings.pressureOffset = ATMO_PROPERTY(MPL3115Pressure, pressureOffset); // Offset pressure correction = 4*-128 = -512Pa (8 bits signed integer)
config.MPLsettings.altitudeOffset = ATMO_PROPERTY(MPL3115Pressure, altitudeOffset); // Offset altitude correction = 128m (signed 8 bits integer)
config.MPLsettings.tempOffset = ATMO_PROPERTY(MPL3115Pressure, tempOffset); // Offset temperature correction -8°C (0.0625°C/LSB)
config.MPLsettings.fifoMode = FIFO_DISABLED; // FIFO mode disabled
config.MPLsettings.fifoWatermark = 5; // 6 bits to set the number of FIFO samples required to trigger a watermark interrupt.
config.MPLsettings.fifoINTpin = FIFO_INT1; // set pin INT1 as output for FIFO interrupt
return ( ATMO_MPL3115_Init(&config) == ATMO_MPL3115_Status_Success ) ? ATMO_Status_Success : ATMO_Status_Fail;
}
ATMO_Status_t MPL3115Pressure_setEnabled(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_MPL3115_SetEnabled(true);
return ATMO_Status_Success;
}
ATMO_Status_t MPL3115Pressure_setDisabled(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_MPL3115_SetEnabled(false);
return ATMO_Status_Success;
}
ATMO_Status_t MPL3115Pressure_setEnabledDisabled(ATMO_Value_t *in, ATMO_Value_t *out) {
bool enabled = false;
ATMO_GetBool(in, &enabled);
ATMO_MPL3115_SetEnabled(enabled);
return ATMO_Status_Success;
}
ATMO_Status_t MPL3115Pressure_readAltitude(ATMO_Value_t *in, ATMO_Value_t *out) {
uint32_t altitudeMeters;
if(ATMO_MPL3115_GetAltitude(&altitudeMeters) != ATMO_MPL3115_Status_Success)
{
ATMO_CreateValueVoid(out);
return ATMO_Status_Fail;
}
ATMO_CreateValueInt(out, (int)altitudeMeters);
return ATMO_Status_Success;
}
ATMO_Status_t MPL3115Pressure_readPressure(ATMO_Value_t *in, ATMO_Value_t *out) {
uint32_t pressurePa;
if(ATMO_MPL3115_GetPressure(&pressurePa) != ATMO_MPL3115_Status_Success)
{
ATMO_CreateValueVoid(out);
return ATMO_Status_Fail;
}
ATMO_CreateValueInt(out, (int)pressurePa);
return ATMO_Status_Success;
}
ATMO_Status_t MPL3115Pressure_readPressureKpa(ATMO_Value_t *in, ATMO_Value_t *out) {
uint32_t pressurePa;
if(ATMO_MPL3115_GetPressure(&pressurePa) != ATMO_MPL3115_Status_Success)
{
ATMO_CreateValueVoid(out);
return ATMO_Status_Fail;
}
ATMO_CreateValueInt(out, (int)(pressurePa/1000));
return ATMO_Status_Success;
}
ATMO_Status_t TSL2572AmbientLight_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t TSL2572AmbientLight_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_TSL2572_Config_t config;
config.address = ATMO_PROPERTY(TSL2572AmbientLight, i2cAddress);
config.i2cDriverInstance = ATMO_PROPERTY(TSL2572AmbientLight, i2cInstance);
return ( ATMO_TSL2572_Init(&config) == ATMO_TSL2572_Status_Success ) ? ATMO_Status_Success : ATMO_Status_Fail;
}
ATMO_Status_t TSL2572AmbientLight_setEnabled(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_TSL2572_SetEnabled(true);
return ATMO_Status_Success;
}
ATMO_Status_t TSL2572AmbientLight_setDisabled(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_TSL2572_SetEnabled(false);
return ATMO_Status_Success;
}
ATMO_Status_t TSL2572AmbientLight_setEnabledDisabled(ATMO_Value_t *in, ATMO_Value_t *out) {
bool enabled = false;
ATMO_GetBool(in, &enabled);
ATMO_TSL2572_SetEnabled(enabled);
return ATMO_Status_Success;
}
ATMO_Status_t TSL2572AmbientLight_readAmbientLight(ATMO_Value_t *in, ATMO_Value_t *out) {
float lightLux;
if(ATMO_TSL2572_GetAmbientLight(&lightLux) != ATMO_TSL2572_Status_Success)
{
ATMO_CreateValueVoid(out);
return ATMO_Status_Fail;
}
ATMO_CreateValueInt(out, (int)lightLux);
return ATMO_Status_Success;
}
ATMO_Status_t CCS811AirQuality_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t CCS811AirQuality_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CCS811_Config_t config;
config.operatingMode = ATMO_PROPERTY(CCS811AirQuality, operatingMode);
config.address = ATMO_PROPERTY(CCS811AirQuality, i2cAddress);
config.i2cDriverInstance = ATMO_PROPERTY(CCS811AirQuality, i2cInstance);
return ( ATMO_CCS811_Init(&config) == ATMO_CCS811_Status_Success ) ? ATMO_Status_Success : ATMO_Status_Fail;
}
ATMO_Status_t CCS811AirQuality_setEnabled(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CCS811_SetEnabled(true);
return ATMO_Status_Success;
}
ATMO_Status_t CCS811AirQuality_setDisabled(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CCS811_SetEnabled(false);
return ATMO_Status_Success;
}
ATMO_Status_t CCS811AirQuality_setEnabledDisabled(ATMO_Value_t *in, ATMO_Value_t *out) {
bool enabled = false;
ATMO_GetBool(in, &enabled);
ATMO_CCS811_SetEnabled(enabled);
return ATMO_Status_Success;
}
ATMO_Status_t CCS811AirQuality_readTVOC(ATMO_Value_t *in, ATMO_Value_t *out) {
uint16_t tvoc;
if(ATMO_CCS811_GetTVOC(&tvoc) == ATMO_CCS811_Status_Success)
{
ATMO_CreateValueUnsignedInt(out, (unsigned int)tvoc);
}
else
{
ATMO_CreateValueVoid(out);
}
return ATMO_Status_Success;
}
ATMO_Status_t CCS811AirQuality_readCO2(ATMO_Value_t *in, ATMO_Value_t *out) {
uint16_t co2;
if(ATMO_CCS811_GetCO2(&co2) == ATMO_CCS811_Status_Success)
{
ATMO_CreateValueInt(out, (int)co2);
}
else
{
ATMO_CreateValueVoid(out);
}
return ATMO_Status_Success;
}
ATMO_Status_t Apps_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Apps_displayPage(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(Apps, x), ATMO_PROPERTY(Apps, y), false);
return ATMO_Status_Success;
}
ATMO_Status_t Apps_onDisplayed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Apps_topRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Apps_bottomRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Apps_topLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Apps_bottomLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Apps_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_PAGE_Config_t config;
config.hidden = ATMO_PROPERTY(Apps, pageHidden);
config.textColor = ATMO_PROPERTY(Apps, textColor);
config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(Apps, topRightButtonEnabled),
ATMO_PROPERTY(Apps,bottomRightButtonEnabled), ATMO_PROPERTY(Apps, topLeftButtonEnabled), ATMO_PROPERTY(Apps, bottomLeftButtonEnabled));
config.x = ATMO_PROPERTY(Apps, x);
config.x = ATMO_PROPERTY(Apps, x);
config.y = ATMO_PROPERTY(Apps, y);
strncpy(config.topLeftButtonLabel, ATMO_PROPERTY(Apps, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.topRightButtonLabel, ATMO_PROPERTY(Apps, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(Apps, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(Apps, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
config.spanX = ATMO_PROPERTY(Apps, spanX);
config.spanY = ATMO_PROPERTY(Apps, spanY);
config.title = ATMO_PROPERTY(Apps, pageTitle);
config.titleHidden = ATMO_PROPERTY(Apps, titleHidden);
ATMO_UI_SINGLEICONTEXT_Init(&config);
ATMO_VARIABLE(Apps, pageHandle) = config.templateInstance;
ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(Apps, label));
ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(Apps, icon));
ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(Apps,pageHandle), ATMO_ABILITY(Apps, onDisplayed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Apps,pageHandle), 1, ATMO_ABILITY(Apps, topRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Apps,pageHandle), 2, ATMO_ABILITY(Apps, bottomRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Apps,pageHandle), 3, ATMO_ABILITY(Apps, topLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Apps,pageHandle), 4, ATMO_ABILITY(Apps, bottomLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(Apps, onLeave));
return ATMO_Status_Success;
}
ATMO_Status_t Apps_onLeave(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Apps_setLabel(ATMO_Value_t *in, ATMO_Value_t *out) {
char label[32];
if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)
{
ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(Apps,pageHandle), label);
}
else
{
return ATMO_Status_Fail;
}
return ATMO_Status_Success;
}
ATMO_Status_t SlowInterval_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t SlowInterval_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_INTERVAL_Handle_t intervalHandle;
ATMO_INTERVAL_AddAbilityInterval(
ATMO_PROPERTY(SlowInterval, instance),
ATMO_ABILITY(SlowInterval, interval),
ATMO_PROPERTY(SlowInterval, time),
&intervalHandle
);
return ATMO_Status_Success;
}
ATMO_Status_t SlowInterval_interval(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedSystemStatusDisplay_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedSystemStatusDisplay_displayPage(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(EmbeddedSystemStatusDisplay, x), ATMO_PROPERTY(EmbeddedSystemStatusDisplay, y), false);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedSystemStatusDisplay_onDisplayed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedSystemStatusDisplay_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_PAGE_Config_t config;
config.hidden = ATMO_PROPERTY(EmbeddedSystemStatusDisplay, pageHidden);
config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(EmbeddedSystemStatusDisplay, topRightButtonEnabled),
ATMO_PROPERTY(EmbeddedSystemStatusDisplay,bottomRightButtonEnabled), ATMO_PROPERTY(EmbeddedSystemStatusDisplay, topLeftButtonEnabled), ATMO_PROPERTY(EmbeddedSystemStatusDisplay, bottomLeftButtonEnabled));
config.x = ATMO_PROPERTY(EmbeddedSystemStatusDisplay, x);
config.y = ATMO_PROPERTY(EmbeddedSystemStatusDisplay, y);
strncpy(config.topLeftButtonLabel, ATMO_PROPERTY(EmbeddedSystemStatusDisplay, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.topRightButtonLabel, ATMO_PROPERTY(EmbeddedSystemStatusDisplay, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(EmbeddedSystemStatusDisplay, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(EmbeddedSystemStatusDisplay, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
config.spanX = ATMO_PROPERTY(EmbeddedSystemStatusDisplay, spanX);
config.spanY = ATMO_PROPERTY(EmbeddedSystemStatusDisplay, spanY);
config.title = ATMO_PROPERTY(EmbeddedSystemStatusDisplay, pageTitle);
config.titleHidden = ATMO_PROPERTY(EmbeddedSystemStatusDisplay, titleHidden);
ATMO_UI_SYSTEMSTATUS_Init(&config);
}
ATMO_Status_t EmbeddedNxpRpkUserButtons_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedNxpRpkUserButtons_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_MK64F_GPIO_EnableResetCombo(ATMO_PROPERTY(EmbeddedNxpRpkUserButtons, enableResetCombo));
ATMO_MK64F_GPIO_EnableDisplayToggleCombo(ATMO_PROPERTY(EmbeddedNxpRpkUserButtons, enableDisplayToggleCombo));
ATMO_MK64F_UserButton_RegisterAbilityHandle(ATMO_MK64F_SW1_Pushed, ATMO_ABILITY(EmbeddedNxpRpkUserButtons, topRightPushed));
ATMO_MK64F_UserButton_RegisterAbilityHandle(ATMO_MK64F_SW2_Pushed, ATMO_ABILITY(EmbeddedNxpRpkUserButtons, bottomRightPushed));
ATMO_MK64F_UserButton_RegisterAbilityHandle(ATMO_MK64F_SW3_Pushed, ATMO_ABILITY(EmbeddedNxpRpkUserButtons, topLeftPushed));
ATMO_MK64F_UserButton_RegisterAbilityHandle(ATMO_MK64F_SW4_Pushed, ATMO_ABILITY(EmbeddedNxpRpkUserButtons, bottomLeftPushed));
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedNxpRpkUserButtons_topRightPushed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedNxpRpkUserButtons_bottomRightPushed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedNxpRpkUserButtons_topLeftPushed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedNxpRpkUserButtons_bottomLeftPushed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_SX9500_Config_t config;
config.address = ATMO_PROPERTY(SX9500Touch, i2cAddress);
config.i2cDriverInstance = ATMO_PROPERTY(SX9500Touch, i2cInstance);
config.gpioDriverInstance = ATMO_PROPERTY(SX9500Touch, gpioInstance);
config.interruptEnabled = ATMO_PROPERTY(SX9500Touch, interruptEnabled);
config.interruptPin = ATMO_PROPERTY(SX9500Touch, interruptGpio);
ATMO_SX9500_Init(&config);
ATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Up, ATMO_ABILITY(SX9500Touch, pressUp));
ATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Down, ATMO_ABILITY(SX9500Touch, pressDown));
ATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Left, ATMO_ABILITY(SX9500Touch, pressLeft));
ATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Right, ATMO_ABILITY(SX9500Touch, pressRight));
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_getTouchData(ATMO_Value_t *in, ATMO_Value_t *out) {
return;
}
ATMO_Status_t SX9500Touch_pressUp(ATMO_Value_t *in, ATMO_Value_t *out) {
SX9500_TouchState_t touchState;
ATMO_GetBinary(in, &touchState, sizeof(touchState));
ATMO_CreateValueBinary(out, &touchState, sizeof(touchState));
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_pressDown(ATMO_Value_t *in, ATMO_Value_t *out) {
SX9500_TouchState_t touchState;
ATMO_GetBinary(in, &touchState, sizeof(touchState));
ATMO_CreateValueBinary(out, &touchState, sizeof(touchState));
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_pressLeft(ATMO_Value_t *in, ATMO_Value_t *out) {
SX9500_TouchState_t touchState;
ATMO_GetBinary(in, &touchState, sizeof(touchState));
ATMO_CreateValueBinary(out, &touchState, sizeof(touchState));
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_pressRight(ATMO_Value_t *in, ATMO_Value_t *out) {
SX9500_TouchState_t touchState;
ATMO_GetBinary(in, &touchState, sizeof(touchState));
ATMO_CreateValueBinary(out, &touchState, sizeof(touchState));
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_PAGE_CONTROLLER_Config_t config;
config.enableUpDownNavLabels = ATMO_PROPERTY(EmbeddedPageController, upDownNavigationLabelsEnabled);
config.enableLeftRightNavLabels = ATMO_PROPERTY(EmbeddedPageController, leftRightNavigationLabelsEnabled);
ATMO_UI_Page_SetConfiguration(&config);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_displayRootPage(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_DisplayRootPage();
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_navigateUp(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_UP);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_navigateDown(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_DOWN);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_navigateLeft(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_LEFT);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_navigateRight(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_RIGHT);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_processTopRightButton(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessUserButton(1);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_processBottomRightButton(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessUserButton(2);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_processTopLeftButton(ATMO_Value_t *in, ATMO_Value_t *out) {
...
This file has been truncated, please download it to see its full contents.
import sys
import binascii
import struct
import time
from bluepy.btle import UUID, Peripheral
import datetime
import logging
import paho.mqtt.client as paho #mqtt library
#some libraries are also not required
broker="127.0.0.1" #the local device i.e., rpi is the host of MQTT though you can specify IP of any external server.
#define callback
def on_message(client, userdata, message):
time.sleep(1)
print("received message =",str(message.payload.decode("utf-8")))
client= paho.Client("client-001")
#create client object client1.on_publish = on_publish
#assign function to callback client1.connect(broker,port)
#establish connection client1.publish("house/bulb1","on")
######Bind function to callback
client.on_message=on_message
deviceID="NXP_1" #giving specific ID to device, so in large area where many are deployed its easy to identify the source of data.
#UUIDs= ID of data. You get them from rapid iot studio.
#Each one are for different fields
service_uuid = UUID("1305b3ca-096e-4366-9f68-1ae8df01f278")
char_light_uuid = UUID("1305b3ca-096e-4366-9f68-1ae8df01f27b")
char_temp_uuid = UUID("1305b3ca-096e-4366-9f68-1ae8df01f279")
char_humid_uuid = UUID("1305b3ca-096e-4366-9f68-1ae8df01f27a")
char_pressure_uuid = UUID("1305b3ca-096e-4366-9f68-1ae8df01f27c")
char_co2_uuid = UUID("bec2f36b-e4c4-455d-90a4-25b0e8c255b5")
char_voc_uuid = UUID("1305b3ca-096e-4366-9f68-1ae8df01f27d")
deviceFrequency=8
#delay of sending the data - 2
#takes input of device adress and if no adress present then logs error
#so that you dont need to run different scripts for different devices and only one will do the job
if len(sys.argv) != 2:
print("Fatal, must pass device address:", sys.argv[0], "<device address="">")
quit()
p = Peripheral(sys.argv[1])
print("Connected")
#for service in p.getServices():
# print(service.uuid)
ButtonService=p.getServiceByUUID(service_uuid)
print("Got service")
try:
ch_ligth = ButtonService.getCharacteristics(char_light_uuid)[0]
ch_temp = ButtonService.getCharacteristics(char_temp_uuid)[0]
ch_humid = ButtonService.getCharacteristics(char_humid_uuid)[0]
ch_pressure = ButtonService.getCharacteristics(char_pressure_uuid)[0]
ch_voc = ButtonService.getCharacteristics(char_voc_uuid)[0]
ch_co2 = ButtonService.getCharacteristics(char_co2_uuid)[0]
#trying to get and store the data
print("Got characteristics")
while 1:
print("read")
#parsing and converting the data to useab;e form
lightVal = str(struct.unpack('<f', ch_ligth.read())[0])
tempVal = str(struct.unpack('<f', ch_temp.read())[0])
humidVal = str(struct.unpack('<f', ch_humid.read())[0])
PressureVal = str(struct.unpack('<f', ch_pressure.read())[0])
co2Val = str(struct.unpack('<f', ch_co2.read())[0])
vocVal = str(struct.unpack('<f', ch_voc.read())[0])
#printing all the values for debugging or else
print ("Lux: ",lightVal)
print ("Temp: ",tempVal)
print ("Humidity: ",humidVal)
print ("Pressure: ",PressureVal)
print ("CO2_val: ",co2Val)
print ("tVOC: ",vocVal)
###########################################
print("connecting to broker ",broker) #connecting ot MQTT broker
client.username_pw_set(username="admin",password="admin") #set the username and password if the broker is secured, which is a must for security
client.connect(broker) #connect to the broker
client.loop_start() #start loop to process received messages
print("publishing ") #for debugging
toPublish=deviceID+";"+"LightVal="+lightVal+";"+"Temp="+tempVal+";"+"Humidity="+humidVal+";"+"AP="+PressureVal+";"+"CO2="+co2Val+";"+"VOC="+vocVal
#taking all the data and making into only one string to make it easier in handeling data from more than one nodes.
DataToPublish=str(toPublish) #mostly the data is in float and gives error while publishing. So we convert it to string
client.publish("MD/data",DataToPublish) #publish to given adress
time.sleep(2) #a delay so that data is sent without any packet loss
client.disconnect() #disconnect from server
client.loop_stop() #stop loop
time.sleep(deviceFrequency) #have more delay in sending next data
finally:
print("will try again") #if it fails in getting reading then, it publishes messege for debugging and you have to rerun the script.
#Code by: Vimarsh
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 3,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Monitoring Dump - Project",
"fill": 1,
"gridPos": {
"h": 8,
"w": 8,
"x": 0,
"y": 0
},
"id": 11,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": false,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 0.5,
"points": true,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Temperature (C)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"temp"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Humidity (%)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "B",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"Humidity"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Air Pressure (millibars)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "C",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"AP"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Weather",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"decimals": null,
"format": "none",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "humidity",
"label": "Humidity",
"logBase": 1,
"max": "200",
"min": "0",
"show": false
}
],
"yaxis": {
"align": false,
"alignLevel": 20
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Monitoring Dump - Project",
"fill": 1,
"gridPos": {
"h": 8,
"w": 8,
"x": 8,
"y": 0
},
"id": 9,
"interval": "",
"legend": {
"alignAsTable": false,
"avg": true,
"current": false,
"hideEmpty": true,
"hideZero": true,
"max": true,
"min": true,
"show": true,
"total": false,
"values": true
},
"lines": false,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 1,
"points": true,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Light (lux)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"LightVal"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Light",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "lumens",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Monitoring Dump - Project",
"fill": 1,
"gridPos": {
"h": 8,
"w": 8,
"x": 16,
"y": 0
},
"id": 12,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": false,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 0.5,
"points": true,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "CO2 (ppm)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"CO2"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "VOC (ppb)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "B",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"VOC"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Gas Concentrations",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"decimals": null,
"format": "none",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "humidity",
"label": "Humidity",
"logBase": 1,
"max": "200",
"min": "0",
"show": false
}
],
"yaxis": {
"align": false,
"alignLevel": 20
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Monitoring Dump - Project",
"fill": 1,
"gridPos": {
"h": 7,
"w": 8,
"x": 0,
"y": 8
},
"id": 4,
"legend": {
"alignAsTable": false,
"avg": true,
"current": false,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": false,
"linewidth": 0,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 1,
"points": true,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Humidity (%)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"Humidity"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Humidity",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "percent",
"label": null,
"logBase": 1,
"max": "100",
"min": "0",
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Monitoring Dump - Project",
"fill": 1,
"gridPos": {
"h": 7,
"w": 8,
"x": 8,
"y": 8
},
"id": 2,
"interval": "",
"legend": {
"alignAsTable": false,
"avg": true,
"current": false,
"hideEmpty": true,
"hideZero": true,
"max": true,
"min": true,
"show": true,
"total": false,
"values": true
},
"lines": false,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 1,
"points": true,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Temperature",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"temp"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Temperature",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "celsius",
"label": null,
"logBase": 1,
"max": "45",
"min": "15",
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Monitoring Dump - Project",
"fill": 1,
"gridPos": {
"h": 7,
"w": 8,
"x": 16,
"y": 8
},
"id": 5,
"legend": {
"alignAsTable": false,
"avg": true,
"current": false,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": false,
"linewidth": 0,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 1,
"points": true,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "Pressure (hPa)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"AP"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Barometeric Pressure",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"decimals": null,
"format": "pressurembar",
"label": "",
"logBase": 1,
"max": "1085",
"min": "870",
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Monitoring Dump - Project",
"fill": 1,
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 15
},
"id": 13,
"legend": {
"alignAsTable": false,
"avg": true,
"current": false,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": false,
"linewidth": 0,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 1,
"points": true,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "CO2 (ppm)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "data",
"orderByTime": "ASC",
"policy": "autogen",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"CO2"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Carbon Dioxide Concentration",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"decimals": null,
"format": "ppm",
"label": "",
"logBase": 1,
"max": null,
"min": "0",
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Monitoring Dump - Project",
"fill": 1,
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 15
},
"id": 8,
"legend": {
"alignAsTable": false,
"avg": true,
"current": false,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": false,
"linewidth": 0,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 1,
"points": true,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"alias": "VOC (ppb)",
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
...
This file has been truncated, please download it to see its full contents.
[
{
"id": "d9a747e6.55694",
"type": "tab",
"label": "Landfills Monitoring - Just the data handeling",
"disabled": false,
"info": ""
},
{
"id": "1e3dc690.705af1",
"type": "function",
"z": "d9a747e6.55694",
"name": "Parsing message",
"func": "var msg433 = {};\nmsg.payload = msg.payload.replace(/(\\r\\n|\\n|\\r)/gm,\"\");\nvar parts433 = msg.payload.split(\";\");\n\nmsg433.name = parts433[0];\nfor (var i=1; i<parts433.length; i++) {\n var keyvalue = parts433[i].split(\"=\");\n if (keyvalue.length===2) {\n msg433[keyvalue[0]] = keyvalue[1];\n }\n}\n\nmsg.msg433 = msg433;\nmsg.topic=\"rflink\";\n\nreturn msg;\n\n/*\n\n// So firstly a generic means of getting incoming items into an object\n\nvar the433 = {};\nmsg.payload = msg.payload.replace(/(\\r\\n|\\n|\\r)/gm,\"\");\nnode.warn(msg.payload);\nvar parts433 = msg.payload.split(\";\");\n\nthe433.p1 = parts433[0];\nthe433.p2 = parts433[1];\nthe433.name = parts433[2];\n\nvar a = 3;\nwhile (a < parts433.length) {\n var bits433 = parts433[a].split(\"=\");\n switch (bits433[0]) {\n case \"ID\": the433.id = bits433[1]; break;\n case \"SWITCH\": the433.switch = bits433[1]; break;\n case \"CMD\": the433.cmd = bits433[1]; break;\n case \"SET_LEVEL\": the433.set_level = parseInt(bits433[1], 10); break;\n case \"TEMP\": the433.temp = parseInt(bits433[1], 16) / 10; break;\n case \"HUM\": the433.hum = parseInt(bits433[1], 10); break;\n case \"BARO\": the433.baro = parseInt(bits433[1], 16); break;\n case \"HSTATUS\": the433.hstatus = parseInt(bits433[1], 10); break;\n case \"BFORECAST\": the433.bforecast = parseInt(bits433[1], 10); break;\n case \"UV\": the433.uv = parseInt(bits433[1], 16); break;\n case \"LUX\": the433.lux = parseInt(bits433[1], 16); break;\n case \"BAT\": the433.bat = bits433[1]; break;\n case \"RAIN\": the433.rain = parseInt(bits433[1], 16) / 10; break;\n case \"RAIN\": the433.rainrate = parseInt(bits433[1], 16) / 10; break;\n case \"WINSP\": the433.winsp = parseInt(bits433[1], 16) / 10; break;\n case \"AWINSP\": the433.awinsp = parseInt(bits433[1], 16) / 10; break;\n case \"WINGS\": the433.wings = parseInt(bits433[1], 16); break;\n case \"WINDIR\": the433.windir = parseInt(bits433[1], 10); break;\n case \"WINCHL\": the433.winchl = parseInt(bits433[1], 16); break;\n case \"WINTMP\": the433.wintmp = parseInt(bits433[1], 16); break;\n case \"CHIME\": the433.chime = parseInt(bits433[1], 10); break;\n case \"SMOKEALERT\": the433.smokealert = bits433[1]; break;\n case \"PIR\": the433.pir = bits433[1]; break;\n case \"CO2\": the433.co2 = parseInt(bits433[1], 10); break;\n case \"SOUND\": the433.sound = parseInt(bits433[1], 10); break;\n case \"KWATT\": the433.kwatt = parseInt(bits433[1], 16); break;\n case \"WATT\": the433.watt = parseInt(bits433[1], 16); break;\n case \"CURRENT\": the433.current = parseInt(bits433[1], 10); break;\n case \"CURRENT2\": the433.current2 = parseInt(bits433[1], 10); break;\n case \"CURRENT3\": the433.current3 = parseInt(bits433[1], 10); break;\n case \"DIST\": the433.dist = parseInt(bits433[1], 10); break;\n case \"METER\": the433.meter = parseInt(bits433[1], 10); break;\n case \"VOLT\": the433.volt = parseInt(bits433[1], 10); break;\n case \"RGBW\": the433.rgbc = parseInt(bits433[1].substring(0, 2), 16);\n the433.rgbw = parseInt(bits433[1].substring(2, 4), 16); break;\n }\n a++;\n}\n\n// SO - the above is general... here is my specific setup for temporarily displaying\n// the Acurite info\nif ((the433.p1 == \"20\") && (the433.name == \"Acurite\") && (the433.id == \"c826\")) {\n if (typeof the433.temp !== 'undefined') temp = the433.temp;\n if (typeof the433.hum !== 'undefined') hum = the433.hum;\n if (typeof the433.bat !== 'undefined') bat = the433.bat;\n if (typeof the433.rain !== 'undefined') rain = the433.rain;\n if (typeof the433.winsp !== 'undefined') winsp = the433.winsp;\n if (typeof the433.windir !== 'undefined') windir = the433.windir;\n\n node.warn(\"Temperature: \" + temp + \"c\");\n node.warn(\"Humidity: \" + hum + \"%\");\n node.warn(\"Battery: \" + bat);\n node.warn(\"Rain: \" + rain + \"mm\");\n node.warn(\"Wind Speed: \" + winsp + \"km/h\");\n node.warn(\"Wind Dir: \" + (windir * 22.5) + \" degrees\");\n}\n\n*/",
"outputs": 1,
"noerr": 0,
"x": 427.566650390625,
"y": 78.56666564941406,
"wires": [
[
"9be88463.3ad4f8"
]
]
},
{
"id": "9be88463.3ad4f8",
"type": "function",
"z": "d9a747e6.55694",
"name": "TEMP conversion",
"func": "if (msg.msg433.Temp!==undefined) {\n msg.msg433.Temp = parseInt(msg.msg433.Temp, 10);\n}\nelse msg.msg433.Temp=-999.0;\nnode.status({fill:\"blue\",shape:\"ring\",text: msg.msg433.Temp });\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 424.566650390625,
"y": 151.56666564941406,
"wires": [
[
"73fbfba4.09c13c"
]
]
},
{
"id": "73fbfba4.09c13c",
"type": "function",
"z": "d9a747e6.55694",
"name": "HUM conversion",
"func": "if (msg.msg433.Humidity!==undefined) {\n msg.msg433.Humidity = parseInt(msg.msg433.Humidity, 10);\n}\nelse msg.msg433.Humidity=-999.0;\nnode.status({fill:\"blue\",shape:\"ring\",text: msg.msg433.Humidity });\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 403.566650390625,
"y": 212.56666564941406,
"wires": [
[
"c1641c3a.d57a68"
]
]
},
{
"id": "c1641c3a.d57a68",
"type": "function",
"z": "d9a747e6.55694",
"name": "Lux Conversion",
"func": "if (msg.msg433.LightVal!==undefined) {\n msg.msg433.LightVal = parseInt(msg.msg433.LightVal);\n}\nelse msg.msg433.LightVal=-999.0;\nnode.status({fill:\"blue\",shape:\"ring\",text: msg.msg433.LightVal });\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 415.566650390625,
"y": 324.56666564941406,
"wires": [
[
"68b1c4dc.f99fe4"
]
]
},
{
"id": "68b1c4dc.f99fe4",
"type": "function",
"z": "d9a747e6.55694",
"name": "AP conversion",
"func": "if (msg.msg433.AP!==undefined) {\n msg.msg433.AP = parseInt(msg.msg433.AP);\n} else msg.msg433.AP=0;\nnode.status({fill:\"blue\",shape:\"ring\",text: msg.msg433.AP });\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 416.566650390625,
"y": 386.56666564941406,
"wires": [
[
"c1c568a8.94aed8"
]
]
},
{
"id": "c1c568a8.94aed8",
"type": "function",
"z": "d9a747e6.55694",
"name": "CO2 conversion",
"func": "if (msg.msg433.CO2!==undefined) {\n msg.msg433.CO2 = parseInt(msg.msg433.CO2);\n}\nelse msg.msg433.CO2=0;\nnode.status({fill:\"blue\",shape:\"ring\",text: msg.msg433.CO2 });\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 406.566650390625,
"y": 456.56666564941406,
"wires": [
[
"f25ba530.f937a"
]
]
},
{
"id": "f25ba530.f937a",
"type": "function",
"z": "d9a747e6.55694",
"name": "VOCconversion",
"func": "if (msg.msg433.VOC!==undefined) {\n msg.msg433.VOC = parseInt(msg.msg433.VOC);\n}\nelse msg.msg433.VOC=-999.0;\nnode.status({fill:\"blue\",shape:\"ring\",text: msg.msg433.VOC });\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 409.566650390625,
"y": 522.5666656494141,
"wires": [
[
"366bce17.619cda"
]
]
},
{
"id": "366bce17.619cda",
"type": "change",
"z": "d9a747e6.55694",
"name": "Set Topic",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "data",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 587.199462890625,
"y": 725.8713531494141,
"wires": [
[
"a6d8ae4e.64533",
"72da7073.37e0e8"
]
]
},
{
"id": "a6d8ae4e.64533",
"type": "function",
"z": "d9a747e6.55694",
"name": "NXP_1",
"func": "msg.payload = {\n ID: msg.msg433.name,\n temp: msg.msg433.Temp,\n Humidity: msg.msg433.Humidity,\n LightVal: msg.msg433.LightVal,\n AP: msg.msg433.AP,\n CO2: msg.msg433.CO2,\n VOC: msg.msg433.VOC\n /*,\n humidity: msg.msg433.HUM,\n battery: msg.msg433.BAT\n */\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 733.566650390625,
"y": 725.5666656494141,
"wires": [
[
"97206fac.6f7c48"
]
]
},
{
"id": "71b1a85d.a3cd18",
"type": "function",
"z": "d9a747e6.55694",
"name": "BAT conversion",
"func": "if (msg.msg433.BAT === undefined) msg.msg433.BAT=\"\";\nnode.status({fill:\"blue\",shape:\"ring\",text: msg.msg433.BAT });\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 265.566650390625,
"y": 661.566650390625,
"wires": [
[]
]
},
{
"id": "b013e816.66a948",
"type": "inject",
"z": "d9a747e6.55694",
"name": "",
"topic": "",
"payload": "ID=NXP_test;LightVal=42;Temp=24.5;Humidity=56;AP=1002;CO2=400;VOC=14",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 192.566650390625,
"y": 115.56666564941406,
"wires": [
[
"1e3dc690.705af1"
]
]
},
{
"id": "72da7073.37e0e8",
"type": "debug",
"z": "d9a747e6.55694",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 839.566650390625,
"y": 776.566650390625,
"wires": []
},
{
"id": "97206fac.6f7c48",
"type": "influxdb out",
"z": "d9a747e6.55694",
"influxdb": "596bad19.de5c64",
"name": "Weather",
"measurement": "data",
"precision": "s",
"retentionPolicy": "",
"x": 986.566650390625,
"y": 721.5666656494141,
"wires": []
},
{
"id": "7392292e.3a1858",
"type": "mqtt in",
"z": "d9a747e6.55694",
"name": "",
"topic": "MD/data",
"qos": "2",
"broker": "aa2bd022.95a698",
"x": 158,
"y": 46,
"wires": [
[
"1e3dc690.705af1"
]
]
},
{
"id": "596bad19.de5c64",
"type": "influxdb",
"z": "",
"hostname": "localhost",
"port": "8086",
"protocol": "http",
"database": "MD",
"name": "Landfill Monitoring",
"usetls": false,
"tls": ""
},
{
"id": "aa2bd022.95a698",
"type": "mqtt-broker",
"z": "",
"name": "Local MQTT",
"broker": "127.0.0.1",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
Comments