Love your pillow doesn't work!

Good morning,
I bought an Arduino MkR1000 to make Iot Bundle projects.
I tried to do Love your pillow project: when plug to the computer, the program works (sometimes) because it sens to my bot the emoticons but not everytime; it also send letters such as J, J dpX, J dZX and so on…The secret command doesn’t work either.
When plug to battery (9v) it dosn’t send messages but just make HeartBeat sounds from buzzer.
I attached my code and foto of the circuit ( in such circuit , battery is missing to make foto more clear).

// ArduinoJson - Version: 5.13.5
#include <ArduinoJson.h>
#include <ArduinoJson.hpp>

#include <SPI.h>
#include <WiFi101.h>
#include <CapacitiveSensor.h>
#include <TelegramBot.h>

#include <Adafruit_SleepyDog.h>

const char* ssid = SECRET_SSID;    //  your network SSID (name)
const char* password = SECRET_PASS;  // your network password
const char BotToken[] = SECRET_TOKEN; // you bot API token

WiFiSSLClient client;
TelegramBot bot (BotToken, client);

unsigned long timer;
bool pressed = false;
String chat_id;
int threshold = 1500; // this value might change depending on the amount of alluminium foil used
int heart_beat=-1;
int Buzzer = 8; // Pin attached to the buzzer

// List of Emoji we are going to send taken from
String emoji[] {
  "\U0001F44A", // fist  
  "\U0001F60D", // eyes
  "\U00002764" // heart

CapacitiveSensor   foil = CapacitiveSensor(5,4);        // 10M resistor between pins 5 & 4, pin 4 is sensor pin, add a wire and or foil if desired

void setup() {
  Serial.print("connecting to ");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
  Serial.println("WiFi connected");

  Watchdog.enable(10000); // Set the timer to 10 sec

void loop() {
  Watchdog.reset(); // If this function is not called within 10 seconds the board will reset itself
    message m = bot.getUpdates(); // Read new messages
      if ( m.chat_id != 0 ){ // Check if there are some updates
      // Check if the text is an emoji and react accordingly
      if(m.text== "u2764" || m.text== "ud83dudc4a" || m.text== "ud83dude0d" ) HeartBeat();
      chat_id = m.chat_id;
    long start = millis();
    long sensor_value =  foil.capacitiveSensor(30);
//   Uncomment this line to debug and calibrate the threshold
  if (sensor_value > threshold && !pressed) { 
    pressed = true;
  else if(sensor_value > threshold && pressed){
    // Avoid the heart_beat value to exceed the emoji[] array length
    if(heart_beat >= sizeof(emoji)/sizeof(String)) heart_beat = 0; 
  else if (sensor_value < threshold && pressed) {
    pressed = false;
    Serial.println(" heart beats");

void SendMessage(int heart_beat) {
  // Check if you know the chat_id of the chat you want to send the message to
  // You cannot send messages without knowing the chat_id
  if(chat_id!=0) bot.sendMessage(chat_id, emoji[heart_beat]);
  // Use heart_beat variable to navigate the array emoji[]

void HeartBeat(){
    tone(Buzzer, 31, 200); // tone(Pin, Note, Duration);
    tone(Buzzer, 31, 400);

and a tab “arduino_secret.h” where I put:

#define SECRET_SSID "SSID Name"
#define SECRET_PASS "Password"
#define SECRET_BOT_TOKEN "Token"

but when I compile it, it says “SECRET_SSID not declared for this scope” so i had to pud my datas insted of SECRET to make it work.



Would you help me to solve these problems?

Io please,

Did you use the project guide here ?

Yes, I follower Every instruction and allo copi ed the code but The bot not always replay to me and sometimes it writes lettere. Even the secret commando doesnt work