ADC issue running IDE 2.9.1

keithco
Posts: 13
Joined: Fri Jun 17, 2022 8:17 pm

ADC issue running IDE 2.9.1

Postby keithco » Wed May 24, 2023 12:43 pm

I am running IDE 2.9.1 and are getting this error (see attachment).

Code: Select all

/*
 * adc.c
 *
 *  Created on: Jul 28, 2022
 *      Author: Keith
 */

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
//#include "esp_adc/adc_continuous.h"
#include "esp_adc/adc_oneshot.h"
#include "esp_adc/adc_cali.h"

#include "MQTT_dialog.h"
#include "mqtt_client.h"
#include "My_Utilities.h"

//ADC Channels
#define ADC1_GPIO1_CHANNEL     ADC_CHANNEL_0
#define ADC1_CHANNEL_0_GPIO_NUM 1

//ADC Attenuation
#define ADC_EXAMPLE_ATTEN           ADC_ATTEN_DB_11

//ADC Calibration
#define ADC_EXAMPLE_CALI_SCHEME     ESP_ADC_CAL_VAL_EFUSE_TP_FIT

extern esp_mqtt_client_handle_t client;

struct
{
	int pool_pressure;
	int pool_temperature;
}
read_adc_values = {0, 0};

void adc_read( adc_channel_t channel )
{
	read_adc_values.pool_pressure = adc_oneshot_read(ADC_CHANNEL_0, ADC1_CHANNEL_0_GPIO_NUM, &adc_raw[0][0]);
	myTaskDelay(10);
}

bool payload_process_adc()
{
	bool match = false;
	static char msg[40];
//	char psi_value = 0;

	if ( topic_is("/pool/adc/pressure") )	// Topic
		{
		match = true;
		if (payload_is ( "/pool/adc/read1" ))	//	"/pool/adc/read/gpio1" is the topic
		{
			printf("got to read adc8\n");
			adc_read(ADC1_GPIO1_CHANNEL);
			itoa(read_adc_values.pool_pressure, msg, 10);
			strcat(msg, " psi");
			esp_mqtt_client_enqueue(client, "/pool/adc/pressure", msg, 0, 1, 0, true);	//	"/pool/adc/pressure" is the topic. Vin Max 2.9V @ 4095 counts
		}
		else
		{
			match = false;
		}
	}
	return match;
}
Attachments
ADC.jpg
ADC.jpg (45.01 KiB) Viewed 763 times

Who is online

Users browsing this forum: No registered users and 116 guests