ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
2#include <libtock-sync/services/alarm.h>
3#include <ulog.h>
4
5int main(void) {
6 ulog_info("ADS1219 Example");
7
8 // Initialize the ADS1219 sensor
10 ulog_error("Failed to initialize ADS1219");
11 return 1;
12 }
13
14 ulog_info("ADS1219 initialized successfully");
15
16 // Read and print voltage and current measurements every 2 seconds
17 while (1) {
18 double voltage = 0.0;
19 double current = 0.0;
20
21 // Read voltage measurement
22 if (ads1219_voltage(&voltage) == ADS1219_SUCCESS) {
23 ulog_info("Voltage: %d mV", (int)(voltage * 1000));
24 } else {
25 ulog_error("Failed to read voltage");
26 }
27
28 // Read current measurement
29 if (ads1219_current(&current) == ADS1219_SUCCESS) {
30 ulog_info("Current: %d mV", (int)(current * 1000));
31 } else {
32 ulog_error("Failed to read current");
33 }
34
35 libtocksync_alarm_delay_ms(2000);
36 }
37
38 return 0;
39}
This file contains all the function prototypes for the ads.c file.
int main()
Definition main.c:4
int ads1219_current(double *current)
This function reads the current ADC ampere value.
Definition ads1219.c:209
int ads1219_reset(void)
This function starts up the ADS1219.
Definition ads1219.c:126
int ads1219_voltage(double *voltage)
This function reads the current ADC voltage value.
Definition ads1219.c:174
@ ADS1219_SUCCESS
Definition ads1219.h:45