- zebra_hun: Hűthető e kulturáltan a Raptor Lake léghűtővel a kánikulában?
- Luck Dragon: Asszociációs játék. :)
- bambano: Bambanő háza tája
- sziku69: Szólánc.
- user2: Kia Ceed Gold 160 1.5 T-GDI MY2024
- gban: Ingyen kellene, de tegnapra
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- Argos: Szeretem az ecetfát
- Magga: PLEX: multimédia az egész lakásban
- sziku69: Fűzzük össze a szavakat :)
-
LOGOUT
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
Postas99
senior tag
válasz
Postas99 #23178 üzenetére
/* Audio streamer with ESP32 and Adafruit elected microphone board.
* Created by Julian Schroeter.
*/
#include <Arduino.h>
#include <WiFi.h>
#include <driver/adc.h>
#define AUDIO_BUFFER_MAX 800
uint8_t audioBuffer[AUDIO_BUFFER_MAX];
uint8_t transmitBuffer[AUDIO_BUFFER_MAX];
uint32_t bufferPointer = 0;
const char* ssid = "YOUR SSID";
const char* password = "YOUR PASSWORD";
const char* host = "YOUR SERVER IP ADDRESS";
bool transmitNow = false;
WiFiClient client;
hw_timer_t * timer = NULL; // our timer
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
void IRAM_ATTR onTimer() {
portENTER_CRITICAL_ISR(&timerMux); // says that we want to run critical code and don't want to be interrupted
int adcVal = adc1_get_voltage(ADC1_CHANNEL_0); // reads the ADC
uint8_t value = map(adcVal, 0 , 4096, 0, 255); // converts the value to 0..255 (8bit)
audioBuffer[bufferPointer] = value; // stores the value
bufferPointer++;
if (bufferPointer == AUDIO_BUFFER_MAX) { // when the buffer is full
bufferPointer = 0;
memcpy(transmitBuffer, audioBuffer, AUDIO_BUFFER_MAX); // copy buffer into a second buffer
transmitNow = true; // sets the value true so we know that we can transmit now
}
portEXIT_CRITICAL_ISR(&timerMux); // says that we have run our critical code
}
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("MY IP address: ");
Serial.println(WiFi.localIP());
adc1_config_width(ADC_WIDTH_12Bit); // configure the analogue to digital converter
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_0db); // connects the ADC 1 with channel 0 (GPIO 36)
const int port = 4444;
while (!client.connect(host, port)) {
Serial.println("connection failed");
delay(1000);
}
Serial.println("connected to server");
timer = timerBegin(0, 80, true); // 80 Prescaler
timerAttachInterrupt(timer, &onTimer, true); // binds the handling function to our timer
timerAlarmWrite(timer, 125, true);
timerAlarmEnable(timer);
}
void loop() {
if (transmitNow) { // checks if the buffer is full
transmitNow = false;
client.write((const uint8_t *)audioBuffer, sizeof(audioBuffer)); // sending the buffer to our server
}
}
Új hozzászólás Aktív témák
Hirdetés
- BESZÁMÍTÁS! ASUS B450 R7 1700X 16GB DDR4 512GB SSD RX 580 8GB Rampage SHIVA Corsair 450W
- BESZÁMÍTÁS! MSI B450M R5 5600 16GB DDR4 512GB SSD RTX 3060 12GB THERMALTAKE Core V21 Enermax 650W
- BESZÁMÍTÁS! MSI B450M R5 3600 16GB DDR4 512GB SSD RTX 2060 Super 8GB THERMALTAKE Core V21 500W
- BESZÁMÍTÁS! Gigabyte B650M R7 7700 32GB DDR5 1TB SSD RTX 5070 12GB BE QUIET! Pure Base 500DX 650W
- Nintendo Switch OLED 20.1.1 okosított Dual-Boot Cfw + 256GB MicroSD + Atmosphere 1.9.1, 3 hó garival
- Samsung Galaxy A52s 128GB, Kártyafüggetlen, 1 Év Garanciával
- AKCIÓ! GIGABYTE GA-Z170X-UD3 Z170 chipset alaplap garanciával hibátlan működéssel
- Eredeti Lenovo 230W töltők - 4X20Z83995
- Akciós Windows 10 / 11 Pro OEM Licenc Kulcs 100% eredeti, jogtiszta!
- 129 - Lenovo Legion Pro 7 (16ARX8H) - AMD Ryzen 9 7945HX, RTX 4080
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft
Város: Budapest
Cég: PC Trade Systems Kft.
Város: Szeged