19 #define A2D_THERM A2D_BASE + 2 20 #define A2D_PHOTO A2D_BASE + 3 26 #define THERMISTORNOMINAL 10000 28 #define TEMPERATURENOMINAL 25 30 #define BCOEFFICIENT 4207.0 // 3977.0 // 4791.8420 // 3977 // 3950 32 #define SERIESRESISTOR 10240 34 #define A2D_PERCISION 255.0 40 #define sA 1.129148E-03 // 1.129241E-03 // 1.129148E-03 41 #define sB 2.34125E-04 // 2.341077E-04 // 2.34125E-04 42 #define sC 8.76741E-08 // 8.775468E-08 // 8.76741E-08 43 #define calibrationOffset -0.5 49 double resistance = 0.0;
70 double kelvin = 0.0, celsius = 0.0;
73 kelvin = 1 / (
sA + (
sB * kelvin) +
sC * kelvin * kelvin * kelvin );
74 celsius = kelvin - 273.15;
88 double kelvin = 0.0, celsius = 0.0;
94 kelvin = 1.0 / kelvin;
96 celsius = kelvin - 273.15;
110 rvalue[index] = analogRead(sensor) ;
115 return rvalue[
MAXREADS] / MAXREADS * 1.0;
122 double fTemp = 0.0, cTemp = 0.0, value = 0.0;
129 fTemp = (cTemp * 1.8) + 32.0;
133 snprintf( buffer, (
SZ_INFO_BUFF - 1),
"[A] %.0fC %.0fF", cTemp, fTemp);
148 value = 256.0 - value;
152 }
else if (value < 50.0) {
154 }
else if (value < 125.0) {
156 }
else if (value < 199.0) {
159 plights =
"Brightest";
170 int main(
int argc,
char *argv[])
181 memset(registry, 0,
sizeof(registry));
182 memset(request, 0,
sizeof(request));
183 strncpy(registry,
"DisplayClient: Raspberry Pi where are you?",
sizeof(registry) - 1);
186 "a2d_display_client",
187 "Send Measured Temperature and Light(lux) to Display Service." 199 }
else if (argc == 2) {
200 strcpy(request, argv[1]);
203 skn_logger(
SD_DEBUG,
"Request Message [%s]", request);
204 skn_logger(
SD_DEBUG,
"Registry Message [%s]", registry);
218 pinMode (
LED, OUTPUT) ;
219 analogWrite(
LED, 0) ;
228 skn_logger(
SD_NOTICE,
"Application Active...");
234 char *service_name =
"lcd_display_service";
243 skn_logger(
" ",
"\nLCD DisplayService (%s) is located at IPv4: %s:%d\n", pre->
name, pre->
ip, pre->
port);
259 if (request[0] == 0) {
266 analogWrite(
LED, 255) ;
272 if ((vIndex == EXIT_FAILURE) && (
gd_i_update == 0)) {
282 if ((vIndex == EXIT_FAILURE) && (
gd_i_update == 0)) {
286 analogWrite(
LED, 0) ;
293 skn_logger(
SD_WARNING,
"Unable to create Network Request.");
301 analogWrite(
LED, 0) ;
int skn_udp_host_create_regular_socket(int port, double rcvTimeout)
char * gd_pch_service_name
int service_registry_entry_count(PServiceRegistry psr)
void signals_cleanup(int sig)
int skn_handle_locator_command_line(int argc, char **argv)
int sknGetModuleTemp(char *buffer)
PServiceRegistry service_registry_get_via_udp_broadcast(int i_socket, char *request)
double betaAdcToCelsius(int rawADC)
int main(int argc, char *argv[])
double adcToOhms(int rawADC)
sig_atomic_t gi_exit_flag
#define calibrationOffset
void service_registry_destroy(PServiceRegistry psreg)
char request[SZ_INFO_BUFF]
#define TEMPERATURENOMINAL
PServiceRequest skn_service_request_create(PRegistryEntry pre, int host_socket, char *request)
int skn_udp_service_request(PServiceRequest psr)
int skn_udp_host_create_broadcast_socket(int port, double rcvTimeout)
double steinhartAdcToCelsius(int rawADC)
double readAverageSensorValue(int sensor)
void skn_program_name_and_description_set(const char *name, const char *desc)
PRegistryEntry service_registry_find_entry(PServiceRegistry psreg, char *serviceName)
#define THERMISTORNOMINAL
int sknGetModuleBright(char *buffer)