How to use SCALAE - IOT
๏ปฟSCALAE WIFI Switch๏ปฟ or SCALAE-IOT is one of our versatile products that can be programmed to accomplish different tasks as needed. The hardware is arranged for a monitoring application with the ability to actuate autonomously and then provide reporting and feedback along with the option for remote control and monitoring. The product falls into our AUTOMATE | CONNECT | CONTROL philosophy.
This application will introduce the product's features and then step you through a basic application of measuring the analog value of a moisture sensor.
The following features give the SCALAE-IOT some punch when used in a field application and enable it to perform a number of tasks effectively.
Specifications | WiFi Switch |
---|---|
Device | PIC Microcontroller: PIC18F2xKxx - SOIC family device |
USB Connectivity | YES - for system configuration local data logging. |
Device Programming | ICSP | USART Bootloader |
Power Supply | Onboard PSU, optimized for low-power operation. |
IO | Reset Button, Opto Isolated inputs, Relay Output |
Temperature Sensors | Dallas 1-Wire (Ruggardised), LM35*, DHT-11* |
Communication | WIFI - ESP8266*, optional module |
USB UART | CH340G |
*These sensors or modules are recommended or have been tested with the SCALAE-IOT.
This project example will demonstrate integrating a soil moisture sensor. This will include how to connect the sensor and then read and interpret the reading.
To get started, your shopping list is the following:
- SCALAE IoT
- Soil Moisture Sensor (Seed Studio)
- Jumpers
- Power Supply
- Dry Soil + jug of water to
The code has been written using MikroC๏ปฟ, which is a C-centric compiler. The compiler is a very useful coding environment as it also includes many integrated libraries.
The code does the following:
- Configure the hardware
- Read the sensor
- Process the reading
- Report the value
The code accomplishes key tasks that are required to set up the hardware, then for the module to repeatedly and reliably perform the task of processing and reporting the value.
The function SetupSystem() is tasked with configuring the MCU. For this application, the device is setup mainly for "safe" operation to prevent any spurious actions taking place. For this reason, all I/O are set to inputs and this prevents the relay from actuating for example.
This then brings us back to the void main() that calls the SetupSystem() function and then once in the while(1) loop, then calls, at this point the main working function.
The SoilMoisture() function takes in the parameter for the analog channel that would be used. This is to accommodate any future changes where an alternative channel may be used.
The MikroC provides a library for reading the Analog inputs, with the only input parameter required being the channel. This is passed in, and the value is returned.
Once the A2D module has performed the calculation, you have a large number that needs to be processed firstly a value that can be reported using an LCD or USART and secondly, a format that can be interpreted and used.
This is performed within the function, converting it to a *char which can be exported using the USART. You can also a LCD display as the value is compatible type.
To view the value being reported, you can use the COMs terminal available from within MikroC. It is located here Tools > Usart Terminal.
๏ปฟ
As noted in the values reported, a high value indicates drier soil and a lower value more moist soil.
In the next installment, we will consider how to use the value that was read and what actions that can be take.