Module Integration Guides
Arduino
Setting up BytebeamArduino SDK
6 min
this section provides step by step instructions on how to set up and start using https //github com/bytebeamio/bytebeam arduino sdk this guide assumes that you are using esp32 development board for this integration and the same instructions will work for esp8266 step 1 getting the sdk you can install the sdk via arduino library manager we recommend installing the latest version of the sdk for this integration follow the below steps to install the sdk open the arduino library manager and search for the bytebeam keyword the bytebeamarduino sdk will pop up go ahead select the latest version (say 1 0 1 ) and hit the install button now you should be able to see the sdk in the arduino ide see sketch > include library > bytebeamarduino within the arduino ide you can also look for example sketches that comes along with the sdk see file > examples > bytebeamarduino within the arduino ide step 2 device provisioning provision device with device config data before you get started with the bytebeamarduino you need to provision your device each device has its own config file which needs to be flashed into its file system when you call the begin method our sdk will look for this device config data and use that in order to establish the secure connection with the remote device at the cloud end for this integration we will go with the default configurations if you want to change the configuration, check out the docid\ aiqczvtetv7jbojjhlr3j guide note on esp32 we use spiffs by default but if you are using esp8266 you should use littlefs by default before getting ahead make sure you have the spiffs file system partition for this you can select the partition table setting under tools section see tools > partition scheme within the arduino ide follow the below steps to provision your device download the device configuration json file from bytebeam cloud by following the docid\ otlg85yo zz3hecvknnyb guide after downloading the config file, open it in your favourite text editor and format the json document once done copy the formatted json document to the clipboard open spiffs provisioning example sketch as per your choice of file system see file > examples > bytebeamarduino > provisioning > spiffsprovisioning within the arduino ide paste the copied content to the deviceconfigwritestr char array, refer below code snippet to do so setup the esp32 board configurations and hit the upload button watch out the serial logs for the provisioning status char deviceconfigwritestr\[device config str length] = r"( { "project id" "espbytebeamsdktest", "broker" "cloud bytebeam io", "port" 8883, "device id" "1", "authentication" { "ca certificate" " begin certificate \nmiifrdcca5sgawibagicb+\nawexetapbgnvbagtcethcm5hdgfrmriweaydvqqhewlcyw5nywxvcmuxfzavbgnv\nbaktdln1ymjpywggr2fyzgvumq8wdqydvqqrewy1njawmtexfdasbgnvbaotc0j5\ndgvizwftlmlvmb4xdtixmdkwmjexmdyym1oxdtmxmdkwmjexmdyym1owdzeomawg\na1uebhmfsw5kawexetapbgnvbagtcethcm5hdgfrmriweaydvqqhewlcyw5nywxv\ncmuxfzavbgnvbaktdln1ymjpywggr2fyzgvumq8wdqydvqqrewy1njawmtexfdas\nbgnvbaotc0j5dgvizwftlmlvmiicijanbgkqhkig9w0baqefaaocag8amiiccgkc\nagear/bnoa/8augzmd/s+7rejurogelqqu9x15kkfkobqcomyxsso65uewpzadpw\nml7gdcdhqftymqdnanbhgat1poifhog64y7uingiwmbh0xjj8g6olrw9rq1gug1q\n/d7x2funza71aixiwel+ksifyidduzmord3rser/bkocggs0wfb54kqivvz1dwsu\nk1wx5exsko7gadxmabdhri2szmn5mszwgl6v0lfskle8ms2qlze50oo2wolnn6xp\nrfrl4bwwkdscqxwkkt4eusndq9hjsuinhdho3guielskljgwj0lq6si74t75rikb\nvvsfeq9mnavs+iuuussjhpjimnn/j64nmgl/r/8fp5tugurhvhxkqkj9h/a7+3ts\nlv2kmsfksxafrgebygij7yr4qu9hx5mxf8pf8egewow/h3cdwcc2mvj11pvpceuj\nedvwe7b4gpm9kx02rnwvumh2fmyqkxx2drrhqgquq+6vron3redmgpqnonjepeow\nzzcgdvxkwztd7ucbczkdn0rymvti/ob5ow8iroxfyggb3iwp796dsxiwbjsqrb9m\nylicgoceqy3vr+8+bhkqlj5/zkte+aa3ktk9uadvxriwkgcejsa/lvyt8qzz0dqn\ngtchyjuhj/xpkhtb0pykb5wtxfjx3g/osbzfrnflcqz9h1mcaweaaancmeawdgyd\nvr0paqh/baqdagkema8ga1udeweb/wqfmambaf8whqydvr0obbyefkl/mtblrz0g\nurneomafbho+lhz+ma0gcsqgsib3dqebcwuaa4icaqalus/ukic5sgo1d2hbj0ak\ns1xjsa2jz+oedshqhmccmzfir3irsuvrmdbabgljdhcelqyxkn6dl/skgwoqoaq5\noer2sey3nmdyw2k2jtdx58hnapzkavir7bdxbibbhmfhjk4ljeubbertnxwbrhvr\ncs4xbnwxvx+nozjqzmxxk89ybsv2dcrgrauez4hqeqv7xc0vkmlzemfkr1nibdr5\nqwbi+7qwiankhggyi27ll2uthpbsy9anlrrme73upiulo7tvkwyc4tydaoq2zrpg\nhy+mxxldftomv/zvmyjopyetrqbfpqorqcm6xopxwsw9b6yddwmnki7ohnovavfd\nwgptuc5oodgfqc3warljx1q2lawzcth58iuf32crtoel2riz4vpurnf/0e2vts1f\npo7v1vy2qin998nwqkxdsll0glteee9huyvk1f8u+fgjj3rjn4bxncn4ocrdjoma\njcaysahv7eeimqryp4jh6rzqzoxld0m9nal8a/y9z2a96fwpzzu/feeoh71t3eo3\nv/cklysialmtshfzdwhnpa6g0nqngn5irl/w1ts1izzjzgwhr6r8wx8oplrzhnrz\n2hdbtxgysem0ihc0b8uzujohthcbwsfxzumpgjg8iycjlfppdwbdw8qrgu8lenux\na0cievjvyatvysoxinv0kg==\n end certificate \n", "device certificate" " begin certificate \nmiiecjccalqgawibagicb+\nawexetapbgnvbagtcethcm5hdgfrmriweaydvqqhewlcyw5nywxvcmuxfzavbgnv\nbaktdln1ymjpywggr2fyzgvumq8wdqydvqqrewy1njawmtexfdasbgnvbaotc0j5\ndgvizwftlmlvmb4xdtiymtewmza3ndcwmloxdtmymtewmza3ndcwmlowktebmbkg\na1uechmszxnwynl0zwjlyw1zzgt0zxn0mqowcaydvqqdewexmiibijanbgkqhkig\n9w0baqefaaocaq8amiibcgkcaqeazsm8cf8fkszwfkzeo52rjrger4z7syrgtb9x\noielje8kmhr+ew217sxuyun+rmjscxrz6jtspkv37popaqilmwtrivq8l46ycrxa\nbi9manlqw0wqafawalfxzm13cuxegzkhuak3ins15jqp0s+owfvww8+hww540i+s\nn6j5yeunwksigoyec82cwvj0qovaxyxjutxgv2idlsxdfjbzq4k9ldbzpzdde0ay\n4x9updrjs5crwt3ok4vwwpmrwot654ctwe8wuja/phtrfbmykqd1jrd2joqtm+u9\npltq7i9/fdnkrqpjuedq04lktbuc2usrkw1vmhpndw22+mdpuwidaqabo1ywvdao\nbgnvhq8baf8ebamcbaawewydvr0lbawwcgyikwybbquhawiwhwydvr0jbbgwfoau\nqx8xnsutnsc6ud46yb8ec74sfp4wdaydvr0rbauwa4ibmtanbgkqhkig9w0baqsf\naaocageacj5ytt47admsxbsv/k7ykuvknwv64lubmqtqmtkrdwniqlafzpjdpieu\n81ktfkklkw6prewdupsby6hkq3zzgvssshbsghboajvlpkk6jply5tzzdij8ug7g\nmczzvqdmzneksg4elghjiyufhd6zujaekkgd1yqpxoivcnodhn2246sxjk23itmz\nb5y1ahu5zydn7ys0oy1l8rcc5iz24icqai//2pipe9orks3qbbi+qy9m+emhcqgb\n48hne5v7x+yf4vitlws3mfk0gsgbdq4owvf/8/d7o0hq8eu5bzxnvf49kd2mwtii\nqdqddnlxzsdgwnwydqrqha0qn02yjxkhnm5gxmp75zmg0bpe4i+pnwuy+b32wfzn\nnczrh4hzzs1cayyyr3e59zspjqcohaucbpe6ouoq8z1v7k9fr31tnffvjg9mbdnx\nv2+pxsp0m7f4e1qfepzxuwyjemxoe/b+iec7pckirkpy46jaivi9onrtr8y5wdir\nbguzpmiymflyzk4ulh7kt7mu/ju/ulnqdu8jvanhhxk3kgv4vv8lsyjseyyp9i1s\nj/eppqbandtr4b2pcv1ig13dinq7rir6q/pnkkrafofzcvoww2bvpoc2dcncyjpb\n1r5qjgxqna8uh+zwths0k/nd9dml1w/rug8hx0vhoie6ajxeepq=\n end certificate \n", "device private key" " begin rsa private key \nmiieowibaakcaqeazsm8cf8fkszwfkzeo52rjrger4z7syrgtb9xoielje8kmhr+\new217sxuyun+\nafawalfxzm13cuxegzkhuak3ins15jqp0s+owfvww8+hww540i+sn6j5yeunwksi\ngoyec82cwvj0qovaxyxjutxgv2idlsxdfjbzq4k9ldbzpzdde0ay4x9updrjs5cr\nwt3ok4vwwpmrwot654ctwe8wuja/phtrfbmykqd1jrd2joqtm+u9pltq7i9/fdnk\nrqpjuedq04lktbuc2usrkw1vmhpndw22+mdpuwidaqabaoibahv3a/ogzbvra4ut\nkka8fv6zezflozfcauuakqujremvlsoprupt2vumuu1srpnt7csmn7azmrw+4gny\nmo5mekdr382fz2dtiuki0kbyvvtnfmtbwaedsibpkzd7m3m1a8hg1whw3sebolw6\njy3zvxn5rase3gkksnkvlu8n5vxgyytn2i6syomkolv3n9v3tzihl3gl2afwad5p\njhjdxz50hhjzuni0mmvuu6m9g26xagxnnibzowv3beubrw5fuvpt/qoboufhckf7\nedcfpiz8ljfpux6fyldooaa7mj+y6yk1qksjbfgg8anhpto/bac1m7yqcjygh9cl\nretvdcecgyea4z+nkjqipriavosmjd6kfmeabkzc4jmart+ktrpojmpwc2wdxu8m\ngp1eqmh/aggory8hcfyl+sif5jvp13dd/47tsk4vhyegnnqrt+wjjuzci0rdvfdh\ntaubjlb4kkstssqpttmg726zd1f32ekzbncy8yqwdmmm1hxak20rpo8cgyea6pn8\nyicirrkfzyvam8m5pceohylbgsnjn2j8dgc8b6sgmg6y4+ruiuxfhc/oq7utovf+\njyqqgemjb22dhcvja6rjuukxxpbcgnnzcemnysohur7nm1bxhwrfoqmameh3pkcl\nl+k4mf6gd1i2hiyd4dd59m5/p3w+quyka4iarp0cgyaf2/uzhyoijsdfw4hjzis9\n2ypttugmi160vqg33gjj/3m9umobjcb3bq6ujxnvrf4r2nmxsyudvglqn32qer7m\n6vjs67i2fsc8akqtqmnpy8nps/elhadtq+wlfircovnhkj2k8hm8z6csxqtc4y9+\ni6mnmgrl8kkgns+ia5ggeqkbgbkln25zswqejte8g3xlvarwqvlhtn4z0/uypwic\npt3gsfjxdzsjiaxddsn2dsyqaorum4zoagx878/qkoysswejxiefao+8ekenmgzy\nxbhs0arfnhzsjklgzsaim6ykzcmfxeu2lhucvtwhuvhsdnrf1iyg1taeb9va3q/8\nwtn9aogban+rik+pvcdpaexngqmsugow8abvv7dybmt99kfnyrdfbt6em68czi90\naolne9p7xzyoyfqdzoljwv8b78dwrbwmiwkhgyb6ms11ggb5j90f8oon4tmjezdw\nkfi0t+zoxn99gcklheg5gfgqhchlehxp9btrytjvz914alvoiaiy\n end rsa private key \n" } } )"; step 3 initialize and start bytebeam client the next step is to initialize and start bytebeam client refer below code snippet to do so // add this include to your sketch \#include \<bytebeamarduino h> // // by including the above header you got the access to the gloabl object named bytebeam // use bytebeam global object to perform the required operations // void setup() { // put your setup code here, to run once // // your application setup stuff goes here // // make sure you initialize the wifi and ntp before stepping ahead // if you want logging via serial monitor, consider initializing the serial as well // setting up the device info i e to be seen in the device shadow bytebeam status = "device is up!"; bytebeam softwaretype = "setup wifi client ino"; bytebeam softwareversion = "1 0 0"; bytebeam hardwaretype = "esp32 dev module"; bytebeam hardwareversion = "rev1"; // this function will initialize and start the bytebeam client // you can over ride the default file system and file name options, if needed // eg bytebeam begin(bytebeamarduino littlefs file system,"/my device config json") if(!bytebeam begin()) { serial println("bytebeam client initialization failed "); } else { serial println("bytebeam client is initialized successfully "); } // // if above call is successfull then your bytebeam client is now configured for the // use you can always check for the logs in serial monitor for the status of the // above call // // check if bytebeam client is connected or disconnected bool connectionstatus = bytebeam isconnected(); if(!connectionstatus) { serial println("bytebeam client is disconnected "); } else { serial println("bytebeam client is connected "); } // call the end method to stop and de initialize the bytebeam client at any point of // time in the code // bytebeam end(); } void loop() { // put your main code here, to run repeatedly // // your application regular stuff goes here // // this function will let you maintain the connection with the bytebeam cloud // in case the connection is lost, it will attempt to reconnect to the bytebeam cloud bytebeam loop(); // software delay, you can customize it as per your application needs delay(5000); } look at the setupclient example sketch for reference see file > examples > bytebeamarduino > esp32 > setupclient within the arduino ide step 4 build and flash application you can build and flash your application as usual with the arduino ide, just setup your board configurations and hit the upload button within the arduino ide

