Introduction #
- This guide is intended to test the features and the basic operation of the device, the NORVI IIOT-AE04-V (Voltage model).
NORVI IIOT-AE04-V test program.
Table of Test Instructions #
Flash the test code firmware before testing the device. Follow the instructions given in the Guide to Flashing the Test Code Firmware guide to flash the binary code.
Testing component/feature | Test | Expected Output/Outputs |
Power | Provide a 24V DC supply. | A red LED inside the device glows. Display turns on. |
Display, Memory card and RTC | Power up the device using a USB cable or a 24V DC supply. | The display starts with the Norvi logo. The device model is displayed. RTC status is displayed. The memory card status is displayed. A final screen with Input, output, and Push Button status appears. A final screen with Input, output, and Push Button status appears. The output-side LED indicators glow in a pattern. |
Digital Inputs | Power up the device using a 24V DC supply. Connect the GND and COM pins and supply the 24V DC to every digital input one by one. | Refer to the expected outputs of the Display Check above. In the input status, the status of all six digital inputs will be 1.(As the inputs are internally pulled up.) The input status changes from 1 to 0, and the input side LED indicator starts to glow accordingly. |
Voltage Inputs and Transistor Outputs | Power up the device using a 24V DC supply. | The status of all six analog inputs will be 0. Toggling output status (from 0 to 1 ) is observed on the display for the 2 transistor outputs, which follows the output side LED indicator blinking pattern.Whenever these LEDs are on, it means the respective transistor is on. |
Voltage Inputs and Transistor Outputs (continued..) | After powering up the device, to check the working of the 6 analog (voltage) inputs, supply a Voltage between 0 and 20 mV to each Voltage input. (Check this link for the wire connection.) To check the working of the 2 transistors, a voltage test is done using a multimeter.To do this, keep the positive probe of the multimeter on the +24V pin of the device. Next, touch the negative probe with the two transistor output pins, one by one, after a 15-second gap. | On the display, the voltage sensed by the Norvi device is displayed.(You can confirm these Voltage values using a multimeter.) The multimeter shows a 24 V DC reading, whenever the transistor is on.(Transistor status is indicated by the respective output side LED indicator and the output status on the display.) |
Push Buttons | Press the three push buttons, one at a time. | The 4-digit analog status of the push button is displayed accordingly on the display. Analog status 1 for the upper button Analog status 2 for the middle button Analog status 3 for the lower button |
RS-485 Communication | For this test, a USB-to-RS-485 converter is required. Connect the RS-485 A and B pins of the Norvi device with the respective A and B pins of the USB to RS-485 converter. Plug the USB end of the USB-to-RS-485 converter into the PC. Power up the Norvi device using a USB Cable. Open the Arduino IDE application. Select the correct COM port of the USB to RS-485 converter in the Arduino IDE and open the serial Monitor. Send the Number ‘5’ in the serial monitor. | On the serial monitor, the “RS485 SUCCESS” statement getting printed is observed. This indicates that the RS-485’s Tx operation is working properly in the Norvi device. Once number “5” is received, all the output side LEDs The indicators will glow simultaneously for a few seconds. Then later, they’ll continue to glow in their previous pattern. This indicates that the RS-485’s RX operation is working properly on the Norvi device. |
Test Program #
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_ADS1X15.h>
#include <EthernetUdp.h>
#include "FS.h"
#include "SD.h"
#include "RTClib.h"
#define ANALOG_PIN_0 32
#define INPUT1 39
#define INPUT2 34
#define INPUT3 35
#define INPUT4 21
#define INPUT5 22
#define INPUT6 15
#define OUTPUT1 26
#define OUTPUT2 27
#define RS485_RX 13
#define RS485_TX 2
#define RS485_FC 4
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_ADS1115 ads1;
Adafruit_ADS1115 ads2;
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int analog_value = 0;
int readSwitch(){
analog_value = analogRead(ANALOG_PIN_0);
return analog_value ; //Read analog
}
unsigned long int timer1 = 0;
// ================================================ SETUP ================================================
void setup() {
Serial.begin(115200);
Serial.println("Hello");
Serial1.begin(9600, SERIAL_8N1, RS485_RX, RS485_TX);
pinMode(RS485_FC, OUTPUT);
digitalWrite(RS485_FC, HIGH); // RS-485
pinMode(OUTPUT1, OUTPUT);
pinMode(OUTPUT2, OUTPUT);
pinMode(INPUT1, INPUT);
pinMode(INPUT2, INPUT);
pinMode(INPUT3, INPUT);
pinMode(INPUT4, INPUT);
pinMode(INPUT5, INPUT);
pinMode(INPUT6, INPUT);
Wire.begin(16,17);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.display();
if (!ads1.begin(0x48)) {
Serial.println("Failed to initialize ADS 1 .");
while (1);
}
if (!ads2.begin(0x49)) {
Serial.println("Failed to initialize ADS 1 .");
while (1);
}
RTC_Check();
delay(1000);
SD_CHECK();
delay(1000);
adcAttachPin(32);
digitalWrite(RS485_FC, HIGH); // RS-485
}
void loop() {
int16_t adc0, adc1, adc2, adc3;
Serial.print(digitalRead(INPUT1));
Serial.print(digitalRead(INPUT2));
Serial.print(digitalRead(INPUT3));
Serial.print(digitalRead(INPUT4));
Serial.print(digitalRead(INPUT5));
Serial.print(digitalRead(INPUT6));
Serial.println("");
Serial.println("");
Serial.print("Push button ");
Serial.println(readSwitch());
Serial.println("");
adc0 = ads1.readADC_SingleEnded(0);
adc1 = ads1.readADC_SingleEnded(1);
adc2 = ads1.readADC_SingleEnded(2);
adc3 = ads1.readADC_SingleEnded(3);
Serial.println("-----------------------------------------------------------");
Serial.print("AIN1: "); Serial.print(adc0); Serial.println(" ");
Serial.print("AIN2: "); Serial.print(adc1); Serial.println(" ");
Serial.print("AIN3: "); Serial.print(adc2); Serial.println(" ");
Serial.print("AIN4: "); Serial.print(adc3); Serial.println(" ");
adc0 = ads2.readADC_SingleEnded(0);
adc1 = ads2.readADC_SingleEnded(1);
adc2 = ads2.readADC_SingleEnded(2);
adc3 = ads2.readADC_SingleEnded(3);
Serial.println("-----------------------------------------------------------");
Serial.print("AIN4: "); Serial.print(adc0); Serial.println(" ");
Serial.print("AIN5: "); Serial.print(adc1); Serial.println(" ");
Serial.print("AIN6: "); Serial.print(adc2); Serial.println(" ");
Serial.print("AIN7: "); Serial.print(adc3); Serial.println(" ");
digitalWrite(OUTPUT1, HIGH);
digitalWrite(OUTPUT2, LOW);
delay(500);
digitalWrite(OUTPUT1, LOW);
digitalWrite(OUTPUT2, HIGH);
delay(500);
digitalWrite(OUTPUT1, LOW);
digitalWrite(OUTPUT2, LOW);
delay(500);
Serial1.println("Hello RS-485");
//Serial2.println("AT");
delay(1000);
}
void displayTime(void) {
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
}
void RTC_Check(){
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
}
else{
if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
int a=1;
while(a<6)
{
displayTime(); // printing time function for oled
a=a+1;
}
}
}
void SD_CHECK(){
uint8_t cardType = SD.cardType();
if(SD.begin(5))
{
Serial.println("Card Mount: success");
Serial.print("Card Type: ");
if(cardType == CARD_MMC){
Serial.println("MMC");
} else if(cardType == CARD_SD){
Serial.println("SDSC");
} else if(cardType == CARD_SDHC){
Serial.println("SDHC");
} else {
Serial.println("Unknown");
}
int cardSize = SD.cardSize() / (1024 * 1024);
Serial.printf("Card Size: %lluMB\n", cardSize);
}
if(!SD.begin(5))
{
Serial.println("NO SD card");
}
}