Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Latest commit 17c41a7 Dec 9, 2019 History
3 contributors

Users who have contributed to this file

@nothans @Shakil-Shahadat @cmesro
ESP8266 --> ThingSpeak Channel
This sketch sends the Wi-Fi Signal Strength (RSSI) of an ESP8266 to a ThingSpeak
channel using the ThingSpeak API (
* ESP8266 Wi-Fi Device
* Arduino 1.8.8+ IDE
* Additional Boards URL:
* Library: esp8266 by ESP8266 Community
* Library: ThingSpeak by MathWorks
ThingSpeak Setup:
* Sign Up for New User Account -
* Create a new Channel by selecting Channels, My Channels, and then New Channel
* Enable one field
* Enter SECRET_CH_ID in "secrets.h"
* Enter SECRET_WRITE_APIKEY in "secrets.h"
Setup Wi-Fi:
* Enter SECRET_SSID in "secrets.h"
* Enter SECRET_PASS in "secrets.h"
Created: Feb 1, 2017 by Hans Scharler (
#include "ThingSpeak.h"
#include "secrets.h"
unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;
#include <ESP8266WiFi.h>
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password
int keyIndex = 0; // your network key index number (needed only for WEP)
WiFiClient client;
void setup() {
void loop() {
// Connect or reconnect to WiFi
if (WiFi.status() != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
while (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network
// Measure Signal Strength (RSSI) of Wi-Fi connection
long rssi = WiFi.RSSI();
// Write value to Field 1 of a ThingSpeak Channel
int httpCode = ThingSpeak.writeField(myChannelNumber, 1, rssi, myWriteAPIKey);
if (httpCode == 200) {
Serial.println("Channel write successful.");
else {
Serial.println("Problem writing to channel. HTTP error code " + String(httpCode));
// Wait 20 seconds to update the channel again