[Device] ERROR: the index 'init' does not exist

I am tryin to work through the " How To Build A Smart Fridge With Electric Imp, Salesforce And Heroku"
Guide. After Connecting the electrimImp Explorer to the Wifi and all the pre Steps I am not able to push the Sensor data into Salesforce.

This is the error message I am receiving.

Does someone got any idea how to fix this?
I also updatet the library version to:
// Accelerometer Library
#require “LIS3DH.device.lib.nut:2.0.2”
// Temperature Humidity sensor Library
#require "HTS221.device.lib.nut:2.0.1

thanks in advance

Post the device script.

1 Like

Guessing it’s this: https://github.com/electricimp/SalesforceHeroku/blob/master/SmartRefrigerator_ExplorerKit_Salesforce.device.nut

You can’t update the library versions, especially over major version number changes, as those version bumps imply that the API has changed.

The code you are using was designed to work with 1.3.0 of the accelerometer library, and so relies on a call that is in the 1.3.0 version of the library (ie, init(), as you can see from your error message). This function does not exist in 2.0.2.

If you go back to the instructions, and use the versions that are in the original code, does it work?

1 Like

first of all thanks for the quick reply.
Yes the code on

is the one i used.
I tried to update to a major version because with the original code I was running into the error 502 Bad Gateway.

What i did not mention was that I was missing on the option to connect Dropbox with Heroku to connect the Herokuapp with the json files. What I did was copying the github repo and connect my github repo with Heroku.

is it possible that this guide works only in Playground because i am trying to do it in a Sandbox?

I’m afraid I don’t know anything about salesforce. The 502 error is from the cloud side, so the issue is in the agent side and could possibly be related to an API on Salesforce that has changed since the example was written.

Paging @terrencebarr who may know more.

1 Like

So your imp actually works … it reads all of the sensors and you can see values for everything? But it’s the logging to the cloud that fails?

You are using Heroku? Is that free and you have an account with them. I wonder if it was free and usable in 2017, but since then, things have changed with Heroku?

When I look at this (link below), it seems like the “free” account doesn’t do so much:

Maybe you need to POST the JSON data to a different online cloud database. If you had your own website, you would be in control of your own cloud. You can get a shared webhost account for $40 … for a whole year. You would have to learn PHP and SQL to receive the data from your imp and display on web pages. Basically you create your own personal API and do whatever you want with no restrictions. You can use your website for all kinds of different imp applications and various other microcontrollers.

1 Like

Well thank you for this suggestions.
yes i used a free Heroku account.
I tried a different guide which worked fine for me.

This solution to connect the imp explorer uses a connected app and requires the IoT functionality in Salesforce enabled which at the moment is only available in Playground.
Best regards

The example in electricimp/ SalesforceHeroku has not been updated in 2 years.

I did a quick check of the code, and have identified a couple issues:

  • The Heroku/Dropbox extension is no longer an option, so the files will need to be uploaded to Heroku via a different option.
  • HTTP requests that send sensor data to the Heroku endpoints are responding with errors.
    • Heroku is able to connect to Salesforce, but the communication between the imp and Heroku does not appear to be querying and updating the database correctly.

I have been working on an application that uses the OAuth2 library to authenticate devices using a Salesforce connected application. The the device can then send data via the Salesforce library. I will publish this application in the examples folder in Salesforce repo when it is done.

1 Like

I found the issue that was causing the 503 errors. There was a breaking change in the npm pg dependency. The quick fix is to update the HerokuApp package.json so that pg uses an older version of pg. I have updated the package.json file in electricimp/SalesforceHeroku repository to use pg v6.3.0.

1 Like